#17 Logging zur Fehleranalyse eingebaut
This commit is contained in:
parent
500ed07d79
commit
c1cdbeebad
@ -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 - 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 - 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 - Beschreibungen angepasst" />
|
<MESSAGE value="#14 Einstellungen reorganisieren - 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>
|
@ -77,25 +77,28 @@ 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:
|
||||||
request = requests.get(
|
try:
|
||||||
'http://{}/report'.format(self.ip), timeout=1)
|
request = requests.get(
|
||||||
self._logger.info("timer request finish")
|
'http://{}/report'.format(self.ip), timeout=1)
|
||||||
if request.status_code == 200:
|
self._logger.info("timer request finish")
|
||||||
self._logger.info("timer request OK, timestamp: " + str(time.time()) + " lastTimestamp: " + str(
|
if request.status_code == 200:
|
||||||
self.lastTimeStamp))
|
self._logger.info("timer request OK, timestamp: " + str(time.time()) + " lastTimestamp: " + str(
|
||||||
timestamp = time.time()
|
self.lastTimeStamp))
|
||||||
data = request.json()
|
timestamp = time.time()
|
||||||
if not self.lastTimeStamp == 0:
|
data = request.json()
|
||||||
intervall = timestamp - self.lastTimeStamp
|
if not self.lastTimeStamp == 0:
|
||||||
# Energy in Wh
|
intervall = timestamp - self.lastTimeStamp
|
||||||
self.energy = self.energy + (intervall * data["power"] / 3600)
|
# Energy in Wh
|
||||||
self._logger.info("Energy: " + self.energy)
|
self.energy = self.energy + (intervall * data["power"] / 3600)
|
||||||
self.lastTimeStamp = timestamp
|
self._logger.info("Energy: " + str(self.energy))
|
||||||
data["energy"] = self.energy
|
self.lastTimeStamp = timestamp
|
||||||
data["onOffButtonEnabled"] = self.onOffButtonEnabled
|
data["energy"] = self.energy
|
||||||
self._plugin_manager.send_plugin_message(self._identifier, data)
|
data["onOffButtonEnabled"] = self.onOffButtonEnabled
|
||||||
except (requests.exceptions.ConnectionError, ValueError):
|
self._plugin_manager.send_plugin_message(self._identifier, data)
|
||||||
self._logger.info('Connection Error Host: {}'.format(self.ip))
|
except (requests.exceptions.ConnectionError, ValueError) as e:
|
||||||
|
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")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user