Automation state attribute trigger with sensor.0xccccccfffea2f120_click

Hi all!

Im asking a probably very simple question here…
Also I’m respectfully summoning @petro, i know hes a god in these stuff :slight_smile:

How to trigger an automation when the sensor name starts with a number and i want to test for its attributes?

 sensor.0xccccccfffea2f120_click		
* linkquality: 89
* battery: 74
* click: off
* friendly_name: Livingroom Switch_click

I know i need to use brackets for the sensor number like
{{states.sensor['0xccccccfffea2f120_click']}}

but i can’t figure out how to test for the click atribute

Any help would be appreciated

Using a template trigger with a value_template that looks something like:

"{{ is_state_attr('sensor.0xccccccfffea2f120_click', 'click', 'on') }}"

That’s assuming you want the automation to trigger when that attribute goes from anything to on.

1 Like

Oh waoh. So an entity name can start with numeric character if its in is_state_attr? That throw me off.

Thanks! Can i buy you a coffe? :slight_smile:

I don’t believe the number at the beginning of the entity ID matters if you use the states(), state_attr(), or is_state_attr() methods.

No prob! I appreciate the offer, but no need.

1 Like