Merge pull request #20 from da4id/Beta

Beta
This commit is contained in:
da4id 2020-01-16 17:46:35 +01:00 committed by GitHub
commit f9a9067bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 435 additions and 32 deletions

View File

@ -2,11 +2,8 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="7e2e0eec-b22e-4d48-8f24-196d1ed9b51a" name="Default Changelist" comment=""> <list default="true" id="7e2e0eec-b22e-4d48-8f24-196d1ed9b51a" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/static/css/shutdownprinter.css" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/static/css/mystromswitch.css" afterDir="false" /> <change beforePath="$PROJECT_DIR$/setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/setup.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/static/js/shutdownprinter.js" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/static/js/mystromswitch.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/templates/shutdownprinter_settings.jinja2" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_settings.jinja2" afterDir="false" />
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/templates/shutdownprinter_sidebar.jinja2" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -15,12 +12,18 @@
<option name="LAST_RESOLUTION" value="IGNORE" /> <option name="LAST_RESOLUTION" value="IGNORE" />
</component> </component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="master" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="ProjectId" id="1TqgYXT1S9U5eM0eUvs1YarA1ll" /> <component name="ProjectId" id="1TqgYXT1S9U5eM0eUvs1YarA1ll" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" /> <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../LEDStrip/RaspberryPi/Python" />
</component> </component>
<component name="RunDashboard"> <component name="RunDashboard">
<option name="ruleStates"> <option name="ruleStates">
@ -45,17 +48,403 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1574193087583</updated> <updated>1574193087583</updated>
</task> </task>
<task id="LOCAL-00012" summary="#6 UI Updates senden und anzeigen">
<created>1574281255732</created>
<option name="number" value="00012" />
<option name="presentableId" value="LOCAL-00012" />
<option name="project" value="LOCAL" />
<updated>1574281255732</updated>
</task>
<task id="LOCAL-00013" summary="#6 UI Updates senden und anzeigen">
<created>1574281522356</created>
<option name="number" value="00013" />
<option name="presentableId" value="LOCAL-00013" />
<option name="project" value="LOCAL" />
<updated>1574281522356</updated>
</task>
<task id="LOCAL-00014" summary="#6 UI Updates senden und anzeigen">
<created>1574281964923</created>
<option name="number" value="00014" />
<option name="presentableId" value="LOCAL-00014" />
<option name="project" value="LOCAL" />
<updated>1574281964923</updated>
</task>
<task id="LOCAL-00015" summary="#6 UI Updates senden und anzeigen">
<created>1574282183896</created>
<option name="number" value="00015" />
<option name="presentableId" value="LOCAL-00015" />
<option name="project" value="LOCAL" />
<updated>1574282183896</updated>
</task>
<task id="LOCAL-00016" summary="#6 UI Updates senden und anzeigen">
<created>1574282504648</created>
<option name="number" value="00016" />
<option name="presentableId" value="LOCAL-00016" />
<option name="project" value="LOCAL" />
<updated>1574282504648</updated>
</task>
<task id="LOCAL-00017" summary="#6 UI Updates senden und anzeigen">
<created>1574282834574</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1574282834574</updated>
</task>
<task id="LOCAL-00018" summary="#6 UI Updates senden und anzeigen">
<created>1574283002922</created>
<option name="number" value="00018" />
<option name="presentableId" value="LOCAL-00018" />
<option name="project" value="LOCAL" />
<updated>1574283002922</updated>
</task>
<task id="LOCAL-00019" summary="#6 UI Updates senden und anzeigen">
<created>1574283107060</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1574283107060</updated>
</task>
<task id="LOCAL-00020" summary="#6 UI Updates senden und anzeigen">
<created>1574283263948</created>
<option name="number" value="00020" />
<option name="presentableId" value="LOCAL-00020" />
<option name="project" value="LOCAL" />
<updated>1574283263948</updated>
</task>
<task id="LOCAL-00021" summary="#6 UI Updates senden und anzeigen">
<created>1574283721587</created>
<option name="number" value="00021" />
<option name="presentableId" value="LOCAL-00021" />
<option name="project" value="LOCAL" />
<updated>1574283721587</updated>
</task>
<task id="LOCAL-00022" summary="#6 UI Updates senden und anzeigen">
<created>1574284067356</created>
<option name="number" value="00022" />
<option name="presentableId" value="LOCAL-00022" />
<option name="project" value="LOCAL" />
<updated>1574284067356</updated>
</task>
<task id="LOCAL-00023" summary="#6 UI Updates senden und anzeigen">
<created>1574284365024</created>
<option name="number" value="00023" />
<option name="presentableId" value="LOCAL-00023" />
<option name="project" value="LOCAL" />
<updated>1574284365024</updated>
</task>
<task id="LOCAL-00024" summary="#6 UI Updates senden und anzeigen">
<created>1574284478325</created>
<option name="number" value="00024" />
<option name="presentableId" value="LOCAL-00024" />
<option name="project" value="LOCAL" />
<updated>1574284478325</updated>
</task>
<task id="LOCAL-00025" summary="#6 UI Updates senden und anzeigen&#10;&#10;logs entfernt">
<created>1574284617102</created>
<option name="number" value="00025" />
<option name="presentableId" value="LOCAL-00025" />
<option name="project" value="LOCAL" />
<updated>1574284617102</updated>
</task>
<task id="LOCAL-00026" summary="#8 Relais ein / ausschalten von Ocotprint aus&#10;&#10;- Toggle Button anzeigen und Events eingebaut&#10;- Api funktionen für Relais ein / aus und toggle implementiert">
<created>1574604851601</created>
<option name="number" value="00026" />
<option name="presentableId" value="LOCAL-00026" />
<option name="project" value="LOCAL" />
<updated>1574604851601</updated>
</task>
<task id="LOCAL-00027" summary="#8 Relais ein / ausschalten von Ocotprint aus&#10;&#10;- Button Style auf default geändert&#10;- get_api_commands implementiert">
<created>1574605785309</created>
<option name="number" value="00027" />
<option name="presentableId" value="LOCAL-00027" />
<option name="project" value="LOCAL" />
<updated>1574605785309</updated>
</task>
<task id="LOCAL-00028" summary="#8 Relais ein / ausschalten von Ocotprint aus&#10;&#10;- url korrigiert">
<created>1574606064523</created>
<option name="number" value="00028" />
<option name="presentableId" value="LOCAL-00028" />
<option name="project" value="LOCAL" />
<updated>1574606064523</updated>
</task>
<task id="LOCAL-00029" summary="#8 Relais ein / ausschalten von Ocotprint aus">
<created>1574606292074</created>
<option name="number" value="00029" />
<option name="presentableId" value="LOCAL-00029" />
<option name="project" value="LOCAL" />
<updated>1574606292074</updated>
</task>
<task id="LOCAL-00030" summary="#8 Relais ein / ausschalten von Ocotprint aus&#10;&#10;- url korrigiert">
<created>1574606712347</created>
<option name="number" value="00030" />
<option name="presentableId" value="LOCAL-00030" />
<option name="project" value="LOCAL" />
<updated>1574606712347</updated>
</task>
<task id="LOCAL-00031" summary="#8 Relais ein / ausschalten von Ocotprint aus&#10;&#10;- Toggle Button enable / disable in Einstellunge&#10;- Databinding von Button">
<created>1574607577396</created>
<option name="number" value="00031" />
<option name="presentableId" value="LOCAL-00031" />
<option name="project" value="LOCAL" />
<updated>1574607577396</updated>
</task>
<task id="LOCAL-00032" summary="#8 Relais ein / ausschalten von Ocotprint aus">
<created>1574607723126</created>
<option name="number" value="00032" />
<option name="presentableId" value="LOCAL-00032" />
<option name="project" value="LOCAL" />
<updated>1574607723126</updated>
</task>
<task id="LOCAL-00033" summary="#8 Relais ein / ausschalten von Ocotprint aus">
<created>1574608168544</created>
<option name="number" value="00033" />
<option name="presentableId" value="LOCAL-00033" />
<option name="project" value="LOCAL" />
<updated>1574608168544</updated>
</task>
<task id="LOCAL-00034" summary="#8 Relais ein / ausschalten von Ocotprint aus">
<created>1574608700412</created>
<option name="number" value="00034" />
<option name="presentableId" value="LOCAL-00034" />
<option name="project" value="LOCAL" />
<updated>1574608700412</updated>
</task>
<task id="LOCAL-00035" summary="#8 Relais ein / ausschalten von Ocotprint aus">
<created>1574609194050</created>
<option name="number" value="00035" />
<option name="presentableId" value="LOCAL-00035" />
<option name="project" value="LOCAL" />
<updated>1574609194050</updated>
</task>
<task id="LOCAL-00036" summary="#8 Relais ein / ausschalten von Ocotprint aus">
<created>1574609901438</created>
<option name="number" value="00036" />
<option name="presentableId" value="LOCAL-00036" />
<option name="project" value="LOCAL" />
<updated>1574609901438</updated>
</task>
<task id="LOCAL-00037" summary="#8 Relais ein / ausschalten von Ocotprint aus">
<created>1574610253466</created>
<option name="number" value="00037" />
<option name="presentableId" value="LOCAL-00037" />
<option name="project" value="LOCAL" />
<updated>1574610253466</updated>
</task>
<task id="LOCAL-00038" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird&#10;#7 Relais einschalten wenn Octoprint gestartet wurde">
<created>1574707150761</created>
<option name="number" value="00038" />
<option name="presentableId" value="LOCAL-00038" />
<option name="project" value="LOCAL" />
<updated>1574707150761</updated>
</task>
<task id="LOCAL-00039" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird&#10;#7 Relais einschalten wenn Octoprint gestartet wurde">
<created>1574707411686</created>
<option name="number" value="00039" />
<option name="presentableId" value="LOCAL-00039" />
<option name="project" value="LOCAL" />
<updated>1574707411686</updated>
</task>
<task id="LOCAL-00040" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird&#10;#7 Relais einschalten wenn Octoprint gestartet wurde&#10;&#10;Logging schreibfehler&#10;Url Fix für Powercycle">
<created>1574707826329</created>
<option name="number" value="00040" />
<option name="presentableId" value="LOCAL-00040" />
<option name="project" value="LOCAL" />
<updated>1574707826329</updated>
</task>
<task id="LOCAL-00041" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird&#10;#7 Relais einschalten wenn Octoprint gestartet wurde">
<created>1574708023156</created>
<option name="number" value="00041" />
<option name="presentableId" value="LOCAL-00041" />
<option name="project" value="LOCAL" />
<updated>1574708023156</updated>
</task>
<task id="LOCAL-00042" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird&#10;#7 Relais einschalten wenn Octoprint gestartet wurde&#10;&#10;Api call fix">
<created>1574708245896</created>
<option name="number" value="00042" />
<option name="presentableId" value="LOCAL-00042" />
<option name="project" value="LOCAL" />
<updated>1574708245896</updated>
</task>
<task id="LOCAL-00043" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird&#10;#7 Relais einschalten wenn Octoprint gestartet wurde&#10;&#10;Api call fix">
<created>1574708497039</created>
<option name="number" value="00043" />
<option name="presentableId" value="LOCAL-00043" />
<option name="project" value="LOCAL" />
<updated>1574708497039</updated>
</task>
<task id="LOCAL-00044" summary="#13 Wenn Request fehlschägt max. 3x versuchen">
<created>1574710870028</created>
<option name="number" value="00044" />
<option name="presentableId" value="LOCAL-00044" />
<option name="project" value="LOCAL" />
<updated>1574710870028</updated>
</task>
<task id="LOCAL-00045" summary="#11 Energieverbrauch näherungsweise berechnen">
<created>1574712024409</created>
<option name="number" value="00045" />
<option name="presentableId" value="LOCAL-00045" />
<option name="project" value="LOCAL" />
<updated>1574712024409</updated>
</task>
<task id="LOCAL-00046" summary="#11 Energieverbrauch näherungsweise berechnen">
<created>1574712205852</created>
<option name="number" value="00046" />
<option name="presentableId" value="LOCAL-00046" />
<option name="project" value="LOCAL" />
<updated>1574712205852</updated>
</task>
<task id="LOCAL-00047" summary="#14 Einstellungen reorganisieren">
<created>1574873790898</created>
<option name="number" value="00047" />
<option name="presentableId" value="LOCAL-00047" />
<option name="project" value="LOCAL" />
<updated>1574873790898</updated>
</task>
<task id="LOCAL-00048" summary="#14 Einstellungen reorganisieren">
<created>1574873809876</created>
<option name="number" value="00048" />
<option name="presentableId" value="LOCAL-00048" />
<option name="project" value="LOCAL" />
<updated>1574873809876</updated>
</task>
<task id="LOCAL-00049" summary="#14 Einstellungen reorganisieren&#10;&#10;- Beschreibungen angepasst">
<created>1574874286229</created>
<option name="number" value="00049" />
<option name="presentableId" value="LOCAL-00049" />
<option name="project" value="LOCAL" />
<updated>1574874286229</updated>
</task>
<task id="LOCAL-00050" summary="#15 Beschreibung erstellen">
<created>1574876224274</created>
<option name="number" value="00050" />
<option name="presentableId" value="LOCAL-00050" />
<option name="project" value="LOCAL" />
<updated>1574876224274</updated>
</task>
<task id="LOCAL-00051" summary="#15 Beschreibung erstellen">
<created>1574876349466</created>
<option name="number" value="00051" />
<option name="presentableId" value="LOCAL-00051" />
<option name="project" value="LOCAL" />
<updated>1574876349466</updated>
</task>
<task id="LOCAL-00052" summary="#16 Codereview Octoprint Plugin Repo">
<created>1575192543311</created>
<option name="number" value="00052" />
<option name="presentableId" value="LOCAL-00052" />
<option name="project" value="LOCAL" />
<updated>1575192543311</updated>
</task>
<task id="LOCAL-00053" summary="#17 Logging zur Fehleranalyse eingebaut">
<created>1578938604039</created>
<option name="number" value="00053" />
<option name="presentableId" value="LOCAL-00053" />
<option name="project" value="LOCAL" />
<updated>1578938604039</updated>
</task>
<task id="LOCAL-00054" summary="#17 Logging zur Fehleranalyse eingebaut">
<created>1578939868815</created>
<option name="number" value="00054" />
<option name="presentableId" value="LOCAL-00054" />
<option name="project" value="LOCAL" />
<updated>1578939868816</updated>
</task>
<task id="LOCAL-00055" summary="#17 Logging zur Fehleranalyse eingebaut">
<created>1578940345174</created>
<option name="number" value="00055" />
<option name="presentableId" value="LOCAL-00055" />
<option name="project" value="LOCAL" />
<updated>1578940345174</updated>
</task>
<task id="LOCAL-00056" summary="#17 Logging zur Fehleranalyse eingebaut">
<created>1578941071143</created>
<option name="number" value="00056" />
<option name="presentableId" value="LOCAL-00056" />
<option name="project" value="LOCAL" />
<updated>1578941071143</updated>
</task>
<task id="LOCAL-00057" summary="#17 Logging zur Fehleranalyse eingebaut">
<created>1579188503178</created>
<option name="number" value="00057" />
<option name="presentableId" value="LOCAL-00057" />
<option name="project" value="LOCAL" />
<updated>1579188503178</updated>
</task>
<task id="LOCAL-00058" summary="#17 Logging zur Fehleranalyse eingebaut">
<created>1579190155814</created>
<option name="number" value="00058" />
<option name="presentableId" value="LOCAL-00058" />
<option name="project" value="LOCAL" />
<updated>1579190155814</updated>
</task>
<task id="LOCAL-00059" summary="#17 Logs aufgeräumt">
<created>1579190259362</created>
<option name="number" value="00059" />
<option name="presentableId" value="LOCAL-00059" />
<option name="project" value="LOCAL" />
<updated>1579190259362</updated>
</task>
<task id="LOCAL-00060" summary="#17 Logs aufgeräumt">
<created>1579192359403</created>
<option name="number" value="00060" />
<option name="presentableId" value="LOCAL-00060" />
<option name="project" value="LOCAL" />
<updated>1579192359403</updated>
</task>
<option name="localTasksCounter" value="61" />
<servers /> <servers />
</component> </component>
<component name="UnknownFeatures">
<option featureType="com.intellij.fileTypeFactory" implementationName="*.js" />
</component>
<component name="Vcs.Log.History.Properties">
<option name="COLUMN_ORDER">
<list>
<option value="0" />
<option value="2" />
<option value="3" />
<option value="1" />
</list>
</option>
</component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES"> <option name="TAB_STATES">
<map> <map>
<entry key="MAIN"> <entry key="MAIN">
<value> <value>
<State /> <State>
<option name="COLUMN_ORDER" />
</State>
</value> </value>
</entry> </entry>
</map> </map>
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="#2 Einstellungen für IP Adresse von Switch&#10;#3 Einstellung für Abfrageintervall" />
<MESSAGE value="#5 Rest Api integration" />
<MESSAGE value="#5 Rest Api integration&#10;&#10;- Bugfix plugin_requires" />
<MESSAGE value="#5 Rest Api integration&#10;&#10;- Nullpointer fix" />
<MESSAGE value="#6 UI Updates senden und anzeigen&#10;&#10;- unnötigen Code entfernen, erster Versuch" />
<MESSAGE value="Revert &quot;#6 UI Updates senden und anzeigen&quot;&#10;&#10;This reverts commit f83d4259" />
<MESSAGE value="#6 UI Updates senden und anzeigen" />
<MESSAGE value="#6 UI Updates senden und anzeigen&#10;&#10;logs entfernt" />
<MESSAGE value="#8 Relais ein / ausschalten von Ocotprint aus&#10;&#10;- Toggle Button anzeigen und Events eingebaut&#10;- Api funktionen für Relais ein / aus und toggle implementiert" />
<MESSAGE value="#8 Relais ein / ausschalten von Ocotprint aus&#10;&#10;- Button Style auf default geändert&#10;- get_api_commands implementiert" />
<MESSAGE value="#8 Relais ein / ausschalten von Ocotprint aus&#10;&#10;- url korrigiert" />
<MESSAGE value="#8 Relais ein / ausschalten von Ocotprint aus&#10;&#10;- Toggle Button enable / disable in Einstellunge&#10;- Databinding von Button" />
<MESSAGE value="#8 Relais ein / ausschalten von Ocotprint aus" />
<MESSAGE value="#9 Relais ausschalten wenn Octoprint heruntergefahren wird&#10;#7 Relais einschalten wenn Octoprint gestartet wurde&#10;&#10;Logging schreibfehler&#10;Url Fix für Powercycle" />
<MESSAGE value="#9 Relais ausschalten wenn Octoprint heruntergefahren wird&#10;#7 Relais einschalten wenn Octoprint gestartet wurde" />
<MESSAGE value="#9 Relais ausschalten wenn Octoprint heruntergefahren wird&#10;#7 Relais einschalten wenn Octoprint gestartet wurde&#10;&#10;Api call fix" />
<MESSAGE value="#13 Wenn Request fehlschägt max. 3x versuchen" />
<MESSAGE value="#11 Energieverbrauch näherungsweise berechnen" />
<MESSAGE value="#14 Einstellungen reorganisieren" />
<MESSAGE value="#14 Einstellungen reorganisieren&#10;&#10;- Beschreibungen angepasst" />
<MESSAGE value="#15 Beschreibung erstellen" />
<MESSAGE value="#16 Codereview Octoprint Plugin Repo" />
<MESSAGE value="#17 Logging zur Fehleranalyse eingebaut" />
<MESSAGE value="#17 Logs aufgeräumt" />
<option name="LAST_COMMIT_MESSAGE" value="#17 Logs aufgeräumt" />
</component>
</project> </project>

View File

@ -76,6 +76,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
def _timer_task(self): def _timer_task(self):
if self.ip is not None: if self.ip is not None:
try:
try: try:
request = requests.get( request = requests.get(
'http://{}/report'.format(self.ip), timeout=1) 'http://{}/report'.format(self.ip), timeout=1)
@ -86,19 +87,24 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
intervall = timestamp - self.lastTimeStamp intervall = timestamp - self.lastTimeStamp
# Energy in Wh # Energy in Wh
self.energy = self.energy + (intervall * data["power"] / 3600) self.energy = self.energy + (intervall * data["power"] / 3600)
self._logger.debug(
"Energy: " + str(self.energy) + " interval: " + str(intervall) + " power: " + str(
data["power"]))
self.lastTimeStamp = timestamp self.lastTimeStamp = timestamp
data["energy"] = self.energy data["energy"] = self.energy
data["onOffButtonEnabled"] = self.onOffButtonEnabled data["onOffButtonEnabled"] = self.onOffButtonEnabled
self._plugin_manager.send_plugin_message(self._identifier, data) self._plugin_manager.send_plugin_message(self._identifier, data)
except (requests.exceptions.ConnectionError, ValueError): except (requests.exceptions.ConnectionError, ValueError) as e:
self._logger.info('Connection Error Host: {}'.format(self.ip)) self._logger.exception(e)
except Exception as exp:
self._logger.exception(exp)
else: else:
self._logger.info("Ip is None") self._logger.info("Ip is None")
def _setRelaisState(self, newState): def _setRelaisState(self, newState):
nbRetry = 0 nbRetry = 0
value = '0' value = '0'
if (newState == True): if newState:
value = '1' value = '1'
while nbRetry < 3: while nbRetry < 3:
try: try:
@ -123,14 +129,21 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
value = 'off' value = 'off'
while nbRetry < 3: while nbRetry < 3:
try: try:
try:
self._logger.info("try to send Powercycle Request")
self._logger.info('http://{}/timer'.format(self.ip))
request = requests.post( request = requests.post(
'http://{}/timer'.format(self.ip), params={'mode': value, 'time': time}, timeout=1) 'http://{}/timer'.format(self.ip), params={'mode': value, 'time': time}, timeout=1)
if request.status_code == 200: if request.status_code == 200:
return return
else: else:
self._logger.info("Could not powerCycle Relais, Http Status Code: {}".format(request.status_code)) self._logger.info(
except requests.exceptions.ConnectionError: "Could not powerCycle Relais, Http Status Code: {}".format(request.status_code))
self._logger.info("Error during powerCycle Relais") except requests.exceptions.ConnectionError as e:
self._logger.exception(e)
self._logger.info("Error during powerCycle Relais: " + str(e.message))
except Exception as exp:
self._logger.exception(exp)
nbRetry = nbRetry + 1 nbRetry = nbRetry + 1
def _toggleRelay(self): def _toggleRelay(self):
@ -171,9 +184,10 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
self._setRelaisState(True) self._setRelaisState(True)
def on_shutdown(self): def on_shutdown(self):
self._logger.info("on_shutdown_event")
if self.powerOffOnShutdown: if self.powerOffOnShutdown:
if self.powerOffDelay <= 0: if self.powerOffDelay <= 0:
self._logger.info("Turn on Relais off Shutdown") self._logger.info("Turn off Relais on Shutdown")
self._setRelaisState(False) self._setRelaisState(False)
else: else:
self._logger.info("Turn off Relais on Shutdown Delayed") self._logger.info("Turn off Relais on Shutdown Delayed")

View File

@ -14,7 +14,7 @@ plugin_package = "octoprint_mystromswitch"
plugin_name = "OctoPrint-MyStromSwitch" plugin_name = "OctoPrint-MyStromSwitch"
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.0.1" plugin_version = "1.0.2"
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module # module