Skip to content

Commit

Permalink
dump_json fix
Browse files Browse the repository at this point in the history
  • Loading branch information
c503ghosh committed Oct 18, 2024
1 parent 433640a commit 3085ab6
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions custom_components/dirigera_platform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,21 @@ def handle_dump_data(call):
import dirigera

logger.info("=== START Devices JSON ===")
key = list(hass.data[DOMAIN].keys())[0]

config_data = hass.data[DOMAIN][key]
ip = config_data[CONF_IP_ADDRESS]
token = config_data[CONF_TOKEN]

logger.info("--------------")
if ip == "mock":
logger.info("{ MOCK JSON }")
else:
hub = dirigera.Hub(token, ip)
json_resp = hub.get("/devices")
logger.info(json_resp)
logger.info("--------------")

# we could have multiple hubs set up
for key in hass.data[DOMAIN].keys():
logger.info("--------------")
config_data = hass.data[DOMAIN][key]
ip = config_data[CONF_IP_ADDRESS]
token = config_data[CONF_TOKEN]
if ip == "mock":
logger.info("{ MOCK JSON }")
else:
hub = dirigera.Hub(token, ip)
json_resp = hub.get("/devices")
logger.info(json_resp)
logger.info("--------------")

logger.info("=== END Devices JSON ===")

hass.services.async_register(DOMAIN, "dump_data", handle_dump_data)
return True
Expand Down

0 comments on commit 3085ab6

Please sign in to comment.