mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-20 22:47:01 +01:00
fix callback
This commit is contained in:
@@ -22,6 +22,7 @@ logging.basicConfig(level=logging.DEBUG)
|
|||||||
|
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
|
global panels
|
||||||
# global settings
|
# global settings
|
||||||
logging.info("Connected to MQTT Server")
|
logging.info("Connected to MQTT Server")
|
||||||
# for panel in settings["nspanels"].values():
|
# for panel in settings["nspanels"].values():
|
||||||
@@ -30,10 +31,11 @@ def on_connect(client, userdata, flags, rc):
|
|||||||
client.subscribe("tele/tasmota_nspdev2/RESULT")
|
client.subscribe("tele/tasmota_nspdev2/RESULT")
|
||||||
|
|
||||||
def on_ha_update(entity_id):
|
def on_ha_update(entity_id):
|
||||||
for panel in panels:
|
for panel in panels.values():
|
||||||
panel.ha_event_callback(entity_id)
|
panel.ha_event_callback(entity_id)
|
||||||
|
|
||||||
def on_message(client, userdata, msg):
|
def on_message(client, userdata, msg):
|
||||||
|
global panels
|
||||||
try:
|
try:
|
||||||
if msg.payload.decode() == "":
|
if msg.payload.decode() == "":
|
||||||
return
|
return
|
||||||
@@ -87,7 +89,7 @@ def get_config():
|
|||||||
|
|
||||||
|
|
||||||
def connect_and_loop():
|
def connect_and_loop():
|
||||||
global settings, home_assistant
|
global settings, home_assistant, panels
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
client.on_message = on_message
|
client.on_message = on_message
|
||||||
client.username_pw_set(
|
client.username_pw_set(
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class LovelaceUIPanel:
|
|||||||
if iid in self.hidden_cards:
|
if iid in self.hidden_cards:
|
||||||
return self.hidden_cards[iid]
|
return self.hidden_cards[iid]
|
||||||
|
|
||||||
def on_ha_update(entity_id):
|
def ha_event_callback(self, entity_id):
|
||||||
logging.debug(f"{entity_id} updated/state changed")
|
logging.debug(f"{entity_id} updated/state changed")
|
||||||
# TODO: Check if entity is on current card
|
# TODO: Check if entity is on current card
|
||||||
libs.panel_cmd.entityUpd(self.sendTopic, self.current_card.render())
|
libs.panel_cmd.entityUpd(self.sendTopic, self.current_card.render())
|
||||||
|
|||||||
Reference in New Issue
Block a user