Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Template sensor instead of using a boolean?

$
0
0

@daneboom wrote:

Is it possible, instead of using this automation which flicks on an input boolean, to use a template sensor? I think the latter option is more elegant because

a) it doesn’t rely on one chance for toggling the input boolean (e.g. if HA was being rebooted at 17:00, the boolean would remain off).
b) it would be much cleaner code wise, I wouldn’t need two automations and an input boolean, just one template sensor.

  - alias: Turn_on_bins_icon
    trigger:
      platform: template
      value_template: >
        {% set d = (strptime(states('sensor.bin'), '%d/%m/%y').timestamp() - 24*60*60)|timestamp_custom('%Y-%m-%d') %}{{ states('sensor.date_time') == d ~ ', 17:00' }}
    action:
      - service: input_boolean.turn_on
        data:
          entity_id: input_boolean.bins

I can’t figure out how to turn this template into a different kind of template.

Thanks

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>