Switch time counter

Hi everybody,

Maybe it is a very silly question but i’ve not found it in blog so let me see if someone can help me.

I want to count everyday time switched on but i don’t know how to do that. I wrote something like this but it doesn’t work.


- id: '1590504745677'
  alias: Contador hores piscina
  description: ''
  trigger:
  - entity_id: switch.motor
    platform: state
    to: “on”
  - minutes: /1
    platform: time_pattern
  condition: []
  action:
  - data: {}
    entity_id: counter.contador_minutos_piscina
    service: counter.increment`

I don’t think you need the time pattern trigger (otherwise you’re just counting seconds.) Also you have the wrong quote characters in the first trigger for the “to” parameter. Try:


- id: '1590504745677'
  alias: Contador hores piscina
  description: ''
  trigger:
  - entity_id: switch.motor
    platform: state
    to: 'on'
  condition: []
  action:
  - data: {}
    entity_id: counter.contador_minutos_piscina
    service: counter.increment`

Also you may want to look at the History Stats integration which might do what you want a bit more simply.

@VDRainer @pnbruckner
Thanks both, with history Stats is very easy !!!

1 Like