Closed Aikawa24 closed 1 year ago
Hi @Aikawa24,
thanks for placing this topic - please don't get me wrong, but as I don't have your hardware in place and can't reproduce it at all, I would move this topic to a discussion not an issue. Maybe someone from the community can help you with this. The goal of this project is to work with the Shelly device - I don't aim to make is a "generic" peace of software
In general - is there any error after 4 hours? Have you maybe set the output/log-level in config.ini to DEBUG - maybe this will give you/us a hint where the errors root cause is.
Fabian
hi, ive adopted your script to read json data from a Tasmota 12.4 with hichi ir read head.
ive no python skills and changed only the parts to get the JSON data.
it works, but I get after 4 hours or sometimes after 2 days no updates, the last value hangs and I had to restart the script to work again.
maybe you can look at it and find a error in my changing?
thank you very much
`#!/usr/bin/env python import platform import logging import sys import os if sys.version_info.major == 2: import gobject else: from gi.repository import GLib as gobject import sys import time import requests # for http GET sys.path.insert(1, os.path.join(os.path.dirname(file), '/opt/victronenergy/dbus-systemcalc-py/ext/velib_python')) from vedbus import VeDbusService class DbusMT681Service: def init(self, servicename, paths, productname='MT681', connection='MT681 JSON service'): deviceinstance = 42 customname = 'MT681-Netz' self.dbusservice = VeDbusService("{}.http{:02d}".format(servicename, deviceinstance)) self._paths = paths logging.debug("%s /DeviceInstance = %d" % (servicename, deviceinstance))
Create the management objects, as specified in the ccgx dbus-api document
def _getSerial(self): meter_data = self._getData()
if not meter_data['StatusSNS']['mt681']['Meter_id']: raise ValueError("Response does not contain 'mac' attribute") serial = meter_data['StatusSNS']['mt681']['Meter_id'] return serial def _getSignOfLifeInterval(self): value = 1 if not value: value = 0 return int(value) def _getData(self): URL = "http://192.168.100.23/cm?cmnd=status%208" meter_r = requests.get(url = URL)
check for response
def _signOfLife(self): logging.info("--- Start: sign of life ---") logging.info("Last _update() call: %s" % (self._lastUpdate)) logging.info("Last '/Ac/Power': %s" % (self._dbusservice['/Ac/Power'])) logging.info("--- End: sign of life ---") return True def _update(self):
try:
get data from Device
def _handlechangedvalue(self, path, value): logging.debug("someone else updated %s to %s" % (path, value)) return True # accept the change def main(): try: logging.info("Start"); from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True)
formatting
except Exception as e: logging.critical('Error at %s', 'main', exc_info=e) if name == "main": main() `