Skip to content

Commit

Permalink
account for energy data with multiple relay device, #155
Browse files Browse the repository at this point in the history
  • Loading branch information
jneilliii committed Jul 10, 2021
1 parent 127de45 commit 9a96253
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions octoprint_tasmota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,19 @@ def check_status(self, plugip, plugidx):
if energy_data is not None:
today = datetime.today()
c = self.lookup(response, *["StatusSNS", "ENERGY", "Current"])
if isinstance(c, list):
c = c[int(plugidx)-1]
p = self.lookup(response, *["StatusSNS", "ENERGY", "Power"])
if isinstance(p, list):
p = p[int(plugidx)-1]
t = self.lookup(response, *["StatusSNS", "ENERGY", "Total"])
if isinstance(t, list):
t = t[int(plugidx)-1]
v = self.lookup(response, *["StatusSNS", "ENERGY", "Voltage"])
if isinstance(v, list):
v = v[int(plugidx)-1]
self._tasmota_logger.debug("Energy Data: %s" % energy_data)
self._logger.debug("Inserting data: {} : {}".format(["ip", "idx", "timestamp", "current", "power", "total", "voltage"], [plugip, plugidx, today.isoformat(' '), c, p, t, v]))
db = sqlite3.connect(self.energy_db_path)
cursor = db.cursor()
cursor.execute(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "OctoPrint-Tasmota"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.0.4rc4"
plugin_version = "1.0.4rc5"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 9a96253

Please sign in to comment.