mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 10:08:23 +00:00
adjustments
This commit is contained in:
parent
784dc233b9
commit
5afecb9e6f
@ -32,15 +32,21 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
data = await response.json()
|
data = await response.json()
|
||||||
_LOGGER.debug("Received data from API: %s", data)
|
_LOGGER.debug("Received data from API: %s", data)
|
||||||
|
|
||||||
entities = [
|
entities = []
|
||||||
{
|
for item in data.get("boards", []):
|
||||||
"id": item.get('endpointId', ''),
|
entity_id = item.get('endpointId', '')
|
||||||
"name": item.get("name", f"Entity {item.get('endpointId', '')}"),
|
entity_name = item.get("name", f"Entity {entity_id}")
|
||||||
"state": "on" if item.get("value", False) else "off",
|
entity_value = item.get("value", False)
|
||||||
|
entity_state = "on" if entity_value else "off"
|
||||||
|
_LOGGER.debug("Processing entity: id=%s, name=%s, value=%s, state=%s", entity_id, entity_name, entity_value, entity_state)
|
||||||
|
|
||||||
|
entities.append({
|
||||||
|
"id": entity_id,
|
||||||
|
"name": entity_name,
|
||||||
|
"state": entity_state,
|
||||||
"type": 'switch'
|
"type": 'switch'
|
||||||
}
|
})
|
||||||
for item in data.get("boards", [])
|
|
||||||
]
|
|
||||||
hass.data[DOMAIN][entry.entry_id]["entities"] = entities
|
hass.data[DOMAIN][entry.entry_id]["entities"] = entities
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user