NEWS
LEDA Ledatronic -> Python-> ioBroker
-
Hallo Zusammen!
Ich hab folgendes Anliegen:
Ich bin im Besitz eines Kachelofens mit einem Heizeinsatz mit Abbrandsteuerung von LEDA.
Die Steuerung ist über Wifi verbunden.Was möchte ich....
Die Steuerung hat einen recht altbacken wirkende APP, über welche die momentane Brennraumtemperatur, die Abgastemperatur, der Status der Tür etc. angezeigt werden.
Was mich wirklich interessiert, sind die Meldung eines Heizfehlers (falsches Brenngut, Ofen nicht angebrannt) sowie die Abschaltung der Lüftungsanlage aufgrund von Unterdruck..
Diese Meldungen würde ich gerne auswerten und weiterleiten.Der Abruf der Daten über http-Request etc. ist laut Kundenservice nicht möglich.
Der Kundenservice hat mir auf Nachfrage folgendes geantwortet:"An die Daten können Sie über eine TCP Socket Verbindung kommen Port 10001
Ein Kunde hat das schonmal ausgewertet für Home Assistant
https://gist.github.com/fake666/1915ce1d9839e1c86afe006a3e30c906"
Ich bin in Python überhautpt nicht fit...
kann mir jemand bei der Übersetzung und Anwendung des Skripts in ioBroker weiterhelfen?
""" Support for getting temperature and state from LEDATronic LT3 Wifi devices. configuration.yaml: sensors: - platform: ledatroniclt3 host: 192.168.178.222 """ import logging import socket import datetime; import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import CONF_PORT, CONF_HOST, TEMP_CELSIUS from homeassistant.helpers.entity import Entity import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) DEFAULT_PORT = 10001 PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, vol.Required(CONF_HOST): cv.string, }) LEDA_SENSORS = [] STATUS_START1=b'\x0e' STATUS_START2=b'\xff' STATUS_END1=int(13) STATUS_END2=int(255) class LedatronicComm: def __init__(self, host, port): self.host = host; self.port = port; self.current_temp = None; self.current_state = None; self.current_valve_pos_target = None; self.current_valve_pos_actual = None; self.last_update = None; def update(self): # update at most every 10 seconds if self.last_update != None and (datetime.datetime.now() - self.last_update) < datetime.timedelta(seconds=10): return; self.last_update = datetime.datetime.now(); s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((self.host, self.port)); while True: byte = s.recv(1) if byte == b'': raise Exception("Interrupted"); if byte != STATUS_START1: continue; byte = s.recv(1); if byte == b'': raise Exception("Interrupted"); if byte != STATUS_START2: continue; state = bytearray(); while len(state) < 18: next = s.recv(18 - len(state)); if next == b'': raise Exception("Interrupted"); state += next; if state[16] != STATUS_END1 or state[17] != STATUS_END2: continue; temp = int.from_bytes(state[0:2], byteorder='big'); self.current_temp = temp; self.current_valve_pos_target = state[3]; self.current_valve_pos_actual = state[2]; stateVal = state[4]; if stateVal == 0: self.current_state = "Bereit"; elif stateVal == 2: self.current_state = "Anheizen"; elif stateVal == 3 or stateVal == 4: self.current_state = "Heizbetrieb"; elif stateVal == 7 or stateVal == 8: self.current_state = "Grundglut"; elif stateVal == 97: self.current_state = "Heizfehler"; elif stateVal == 98: self.current_state = "Tuer offen"; else: self.current_state = "Unbekannter Status: " + str(state); break; def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the LEDATRONIC LT3 Wifi sensors.""" host = config.get(CONF_HOST) port = config.get(CONF_PORT) comm = LedatronicComm(host, port); LEDA_SENSORS.append(LedatronicTemperatureSensor(comm)) LEDA_SENSORS.append(LedatronicStateSensor(comm)) LEDA_SENSORS.append(LedatronicValveSensor(comm)) add_entities(LEDA_SENSORS) class LedatronicTemperatureSensor(Entity): """Representation of the LedaTronic main temperatrure sensor.""" def __init__(self, comm): """Initialize the sensor.""" self.comm = comm; @property def name(self): """Return the name of this sensor.""" return "ledatronic_temp" @property def state(self): """Return the current state of the entity.""" return self.comm.current_temp @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return TEMP_CELSIUS def update(self): """Retrieve latest state.""" try: self.comm.update(); except Exception: _LOGGER.error("Failed to get LEDATRONIC LT3 Wifi state.") class LedatronicStateSensor(Entity): """Representation of the LedaTronic state sensor.""" def __init__(self, comm): """Initialize the sensor.""" self.comm = comm; @property def name(self): """Return the name of this sensor.""" return "ledatronic_state" @property def state(self): """Return the current state of the entity.""" return self.comm.current_state def update(self): """Retrieve latest state.""" try: self.comm.update(); except Exception: _LOGGER.error("Failed to get LEDATRONIC LT3 Wifi state.") class LedatronicValveSensor(Entity): """Representation of the LedaTronic valve sensor.""" def __init__(self, comm): """Initialize the sensor.""" self.comm = comm; @property def name(self): """Return the name of this sensor.""" return "ledatronic_valve" @property def state(self): """Return the current state of the entity.""" return self.comm.current_valve_pos_target; @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return '%'; def update(self): """Retrieve latest state.""" try: self.comm.update(); except Exception: _LOGGER.error("Failed to get LEDATRONIC LT3 Wifi state.") @property def device_state_attributes(self): """Show Device Attributes.""" return { "Actual Position": self.comm.current_valve_pos_actual }
-
@sirfauntleroy hey, ich denke das ist die configuration.yaml von homeassistant. wenn das so ist, kann ich nur sagen, das ich meine arlo kameras auch so in den iobroker bekommen habe. ich habe eine homeassistant installation, unter der habe ich die daten der python datei einfach in die configuration.yaml kopiert. bin da selber ein anfänger.
dann unter iobroker den homeassistant adapter installiert. hier sind alle datenpunkte vorhanden, die auch in homeassistant sind. nun kann ich die datenpunkte auch in iobroker nutzen in der vis etc.
lg
-
@thomas-jansen
Danke schonmal!
Ich würde noch hoffen, dass ich nicht auch noch homeassistant in Betriebt nehmen muss
Falls nicht noch ein anderer Profi hier eine Idee hat, das Skript über ioBroker direkt anzuwenden, muss ich wohl diesen Weg beschreiten -
@thomas-jansen
ich hab jetzt mal die Homeassistant-Installation auf dem Nuc durchgeführt und eingerichtet.
Kannst du mir kurz und knapp sagen, wie ich das Skript einfüge und ans Laufen bekomme, ohne, dass ich mich lange einlese? -
@sirfauntleroy Sorry für die späte Antwort, hast Du es hinbekommen?
Das Problem ist, das ich keine Integration finde, die ich installieren kann bezüglich des Ofens. Ohne das glaube ich nicht, das es dir was bringt den Code von oben in die configuration.yaml zu kopieren. Evt. kannst Du den User fake666 mal auf GIT anschreiben, er hat den Code ja auch geschrieben?
Sorry, für ARLO war es einfach, HACS installiert, Arlo Integration aktiviert, den Code in die configuration.yaml und wie schon geschrieben in Iobroker den Adapter installiert. Alle Datenpunkte die ich benötige da...
Tut mir leid, mehr weiß ich auch nicht...
LG
-
Hallo zusammen,
@Sirfauntleroy : wir versuchen an anderer Stelle auch gerade, das Skript für die Ledatronic in HomeAssistant zum Laufen zu bekommen. Die ersten Schritte wurden hier beschrieben.
Viele Grüße, Alois
-
Hi, ich hatte genau die gleiche Anforderung... ->
Habe mit ein Script gebaut um die Informationen zu erhalten:
ledatronic.pydie ich dann über parser einlese.
parser.0.Leda.json -
FYI;
ledatronic.py is running locally in bash... by cron. ->
*/1 * * * * /opt/ledatronic_interface/ledatronic.py >/tmp/ledatronic.log 2>&1
https://gist.github.com/ESDN83/0d2b3eb6b525b46e464b74d278ce235e
https://gist.github.com/fake666/1915ce1d9839e1c86afe006a3e30c906