I have a working automation and trying to make it a blueprint.
Automation:
trigger:
- type: power
platform: device
device_id: 9fc867b39427cefcbc3dda4b33ae8549
entity_id: ea80e231c8789f6ff011d33292ccc5bc
domain: sensor
above: 2
id: tool-starts-being-used
alias: Tool starts being used
in blueprint I did
blueprint:
domain: automation
input:
power_outlet:
name: Power outlet
selector:
entity:
filter:
- domain: switch
- device_class: outlet
trigger:
- type: power
platform: device
device_id: !input power_outlet
entity_id: ????????????????????
domain: sensor
above: 2
id: tool-starts-being-used
alias: Tool starts being used
but I canāt understand how to get entity_id
I see state I need is sensor.node_4_electric_consumption_w and as far as I understand sensor.node_4 is my device_id but I struggle to understand how do I get electric_consumption_w from input
The entity selector you are using is going to return an entity id, but you need to configure it to get sensor entities, not switch entities.
No. A device_id is always a random-looking alphanumeric string like a25920adf0279ae1755cdac06b522a79 .
I donāt work with blueprints much, but I would be very surprised if Device triggers are allowed at allā¦ you should probably be using a Numeric state trigger.
blueprint:
domain: automation
input:
power_outlet:
name: Power outlet
selector:
entity:
filter:
- domain: sensor
device_class: power
trigger:
- platform: numeric_state
entity_id: !input power_outlet
above: 2
id: tool-starts-being-used
alias: Tool starts being used
You can do a device trigger, but there is NO advantage that I know of to torture yourself that way.
Device triggers that populate themselves (basically) in the UI editor use the device triggers because, I donāt know, it probably is closer to the machine type code that is in the back end maybe. The entity triggers are easier to understand and troubleshoot unless you are a machine, IMHO.
Turn on the āea80e231c8789f6ff011d33292ccc5bcā connected thru the ā
9fc867b39427cefcbc3dda4b33ae8549ā
OR
Turn on the ā!input power_outletā.
What makes more sense to you and gives you SOME ability to troubleshoot it, assuming you are not a machine?
Thanks for the answers - I think Iām starting to understand the hierarchy. Device is a physical hardware. Entity is āinterfaceā it is implementing like āsensorā or āpowerā. State gets data from entities.
Reading through the docs over and over.
Ok, Iām much smarter now. Avoiding device triggers and device actions
Something I still struggling with is getting entity from device. Iām trying to let user select single device so I could perform different actions on it - read sensor, turn it on and off etc.
I have my physical switch.
input:
switch_tool:
name: Tool switch
description: Tool that turns the tool ON&OFF
selector:
target:
entity:
domain: switch
Now I try to create a trigger when wattage on device is higher than a threshold.
I know that device has power sensor that is represented by separate entity but I donāt understand how do I retrieve that entity from device? I can workaround this by making user select power entity for this device as a separate input but it will be nice to let them select single device that I would deal in automation.
- alias: Tool starts being used
id: tool-starts-being-used
platform: numeric_state
entity_id: !input switch_tool # ??? I need to get power sensor entity here
attribute: electric_consumption_w
above: 1
Ok, got it - I thought Iām missing something obvious.
I think I will just use multiple inputs for different entities. Thanks a lot for patiently answering at noob questions!