snarky-snark / home-assistant-variables

A custom Home Assistant component for declaring and setting generic variable entities dynamically.
Apache License 2.0
275 stars 16 forks source link

Can I use a binary_sensor #45

Closed rlust closed 3 years ago

rlust commented 3 years ago

Can I use a binary sensor as an input to the tracked entities to count a variable?

snarky-snark commented 3 years ago

Yes, I think you should be able to accomplish that with a configuration like this:

value_template: "{{ (states('binary_sensor.name') }}" 
tracked_entity_id: binary_sensor.name

Does that work?

snarky-snark commented 3 years ago

Or are you trying to count how many times a binary sensor has been toggled?

value_template: "{{ (states('var.this_var') | int) + 1 }}" 
tracked_entity_id: binary_sensor.name