Andrea-Fox / peopleCounter

Code for a cheap people counter based on VL53L1X sensor and ESP32/8266
The Unlicense
95 stars 27 forks source link

Automation Example with Choose #12

Closed noxhirsch closed 3 years ago

noxhirsch commented 3 years ago

This is another automation example which works with HA >0.113 With that you only need one automation for increasing and decreasing the counter. Since I don't know if you want to add this to your examples or replace them, I didn't open a PR and post it here instead.

alias: Person Counter
trigger:
  - platform: mqtt
    topic: peopleCounter/serialdata/tx
action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ trigger.payload == "1" }}'
        sequence:
          - service: input_number.increment
            entity_id: input_number.people_counter
      - conditions:
          - condition: template
            value_template: '{{ trigger.payload == "2" }}'
        sequence:
          - service: input_number.decrement
            entity_id: input_number.people_counter
mode: single
Andrea-Fox commented 3 years ago

I will add that to the automations file. Thanks for the suggestion