#17 Logging zur Fehleranalyse eingebaut

This commit is contained in:
David Zingg 2020-01-13 19:32:25 +01:00
parent 500ed07d79
commit c1cdbeebad
2 changed files with 40 additions and 36 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-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="#17 Logging zur Fehleranalyse eingebaut"> <list default="true" id="7e2e0eec-b22e-4d48-8f24-196d1ed9b51a" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" afterDir="false" />
</list> </list>
@ -48,20 +48,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1574193087583</updated> <updated>1574193087583</updated>
</task> </task>
<task id="LOCAL-00004" summary="#5 Rest Api integration&#10;&#10;- Nullpointer fix">
<created>1574277496115</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1574277496115</updated>
</task>
<task id="LOCAL-00005" summary="#6 UI Updates senden und anzeigen&#10;&#10;- unnötigen Code entfernen, erster Versuch">
<created>1574279164975</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1574279164975</updated>
</task>
<task id="LOCAL-00006" summary="#6 UI Updates senden und anzeigen"> <task id="LOCAL-00006" summary="#6 UI Updates senden und anzeigen">
<created>1574279821388</created> <created>1574279821388</created>
<option name="number" value="00006" /> <option name="number" value="00006" />
@ -391,7 +377,21 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1575192543311</updated> <updated>1575192543311</updated>
</task> </task>
<option name="localTasksCounter" value="53" /> <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>
<option name="localTasksCounter" value="55" />
<servers /> <servers />
</component> </component>
<component name="UnknownFeatures"> <component name="UnknownFeatures">
@ -443,6 +443,7 @@
<MESSAGE value="#14 Einstellungen reorganisieren&#10;&#10;- Beschreibungen angepasst" /> <MESSAGE value="#14 Einstellungen reorganisieren&#10;&#10;- Beschreibungen angepasst" />
<MESSAGE value="#15 Beschreibung erstellen" /> <MESSAGE value="#15 Beschreibung erstellen" />
<MESSAGE value="#16 Codereview Octoprint Plugin Repo" /> <MESSAGE value="#16 Codereview Octoprint Plugin Repo" />
<option name="LAST_COMMIT_MESSAGE" value="#16 Codereview Octoprint Plugin Repo" /> <MESSAGE value="#17 Logging zur Fehleranalyse eingebaut" />
<option name="LAST_COMMIT_MESSAGE" value="#17 Logging zur Fehleranalyse eingebaut" />
</component> </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)
@ -89,13 +90,15 @@ 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.info("Energy: " + self.energy) self._logger.info("Energy: " + str(self.energy))
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.info('Connection Error Host: {}, {}'.format(self.ip, e))
except Exception as exp:
self._logger.info(exp.message)
else: else:
self._logger.info("Ip is None") self._logger.info("Ip is None")