R&D Decision Survey Counter

Hi there

Let’s say i’m working @ R&D department of a company.
Many times during engineering i need opinion from others about design variants.

So i want to count opinions.

I tried the counter option of home assistant but i had no luck.
I need to track four different gui switches for four different design variants. With each hit one of four counter has to be incremented by 1.
I would like that everybody can give his opinion on a Raspberrypi Hass.io Touchscreen Terminal about it. So everybody can pass by and give me a feedback.

It sounds that easy.

Has someone a solution for that?

Create the counters

counter:
  option1_counter:
    name: Option1
    step: 1
  option2_counter:
    name: Option2
    step: 1
  option3_counter:
    name: Option3
    step: 1
  option4_counter:
    name: Option4
    step: 1

Create some input booleans to show on the front end. These show up like switches. They will start as off and when pushed will turn on. When on they trigger the automation below which after it increments the counter, will turn it back off.

input_boolean:
 option1:
    name: Option1
    initial: off
 option2:
    name: Option2
    initial: off
 option3:
    name: Option3
    initial: off
 option4:
    name: Option4
    initial: off

This is the automation that monitors the input boolean, increments the counter and then turns the input_boolean back off.

automation:
- id: ' option1voting'
  alias: Option 1 Automation
  trigger:
    platform: state
    entity_id: input_boolean.option1
    from: 'off'
    to: 'on'
  action:
    - service: counter.increment
      entity_id: counter.option1_counter
    - delay:  '00:00:02'
    - service: homeassistant.turn_off
      entity_id: input_boolean.option1
- id: ' option2voting'
  alias: Option 2 Automation
  trigger:
    platform: state
    entity_id: input_boolean.option2
    from: 'off'
    to: 'on'
  action:
    - service: counter.increment
      entity_id: counter.option2_counter
    - delay:  '00:00:02'
    - service: homeassistant.turn_off
      entity_id: input_boolean.option2
- id: ' option3voting'
  alias: Option 3 Automation
  trigger:
    platform: state
    entity_id: input_boolean.option3
    from: 'off'
    to: 'on'
  action:
    - service: counter.increment
      entity_id: counter.option3_counter
    - delay:  '00:00:02'
    - service: homeassistant.turn_off
      entity_id: input_boolean.option3
- id: ' option4voting'
  alias: Option 4 Automation
  trigger:
    platform: state
    entity_id: input_boolean.option4
    from: 'off'
    to: 'on'
  action:
    - service: counter.increment
      entity_id: counter.option4_counter
    - delay:  '00:00:02'
    - service: homeassistant.turn_off
      entity_id: input_boolean.option4

I’m sure this could be combined into a single automation with some templating.

1 Like

Hi silvrr

You are great.
Added everything to my configuration and it worked without issues.
How about reset the counters?

Best regards
Buhi

See the services section of this page.