Scaffold device automation#26871
Conversation
|
|
||
| async def async_get_triggers(hass: HomeAssistant, device_id: str) -> List[dict]: | ||
| """List device triggers for NEW_NAME devices.""" | ||
| registry = await entity_registry.async_get_registry(hass) |
There was a problem hiding this comment.
Should the script expose the ability to have both device and entity based triggers? Ex: in the case of stateless devices (remotes) there are no entities. Maybe pass the device to a private method to add device triggers, get the entities and then pass them to a private method to add entity triggers if necessary?
There was a problem hiding this comment.
I've added a comment with some commented out code from the ZHA integration.
| ) | ||
|
|
||
|
|
||
| async def async_get_conditions(hass: HomeAssistant, device_id: str): |
There was a problem hiding this comment.
Same as above. Should this expose the ability to do this at both device and entity levels?
There was a problem hiding this comment.
We should aim for device conditions to be a layer on top of existing state conditions. We should not have device conditions that get data that is not available in the state machine.
| return test_is_on | ||
|
|
||
|
|
||
| async def async_get_actions(hass: HomeAssistant, device_id: str) -> List[dict]: |
There was a problem hiding this comment.
Same as above. Should this expose the ability to do this at both device and entity levels?
There was a problem hiding this comment.
Added a comment to the generated code. Let me know if you think that it's enough.
|
|
||
| # Add triggers for each entity that belongs to this integration | ||
| # TODO add your own triggers. It's ok to not have any triggers. | ||
| triggers.append( |
There was a problem hiding this comment.
Should these blocks just be part of the comment above to illustrate how to do this? Or is there value in assuming/treating everything works like an on/off type of device? It looks like the script is designed to treat everything like a toggle entity.
There was a problem hiding this comment.
It was mainly to get tests going and show people how it should look.
You think that we should comment it out to emphasize that it's an example ?
There was a problem hiding this comment.
If you’re not worried that people will leave it in their implementations then leave it.
There was a problem hiding this comment.
Let's leave it in and see what the PRs do.
|
|
||
| # Add conditions for each entity that belongs to this integration | ||
| # TODO add your own conditions. It's ok to not have any conditions. | ||
| conditions.append( |
There was a problem hiding this comment.
Same as above. Should this just be part of the comment?
|
|
||
| # Add actions for each entity that belongs to this integration | ||
| # TODO add your own actions. It's ok to not have any actions. | ||
| actions.append( |
There was a problem hiding this comment.
Same as above. Should this just be part of the comment?
eb20b84 to
ae25772
Compare
|
I have updated the templates to match our new device automation organisation. It's now 3 templates : device_trigger, device_condition, device_action. |
ae25772 to
f0d9812
Compare
Description:
Scaffold script to bootstrap device automations.
python3 -m script.scaffold device_triggerpython3 -m script.scaffold device_conditionpython3 -m script.scaffold device_actionDocs home-assistant/developers.home-assistant#321