How to configure a counter for our CatLitter robot?

I have made a sensor (Arduino Uno with HAL-sensor and some Mysensors-code).
In HA the sensor is detected (heartbeat signal is counting).
The sensor gives a pulse (OFF signal) when the CatLitter robot has cleaned it’s self.

In HA I see this:

CatLitter 3 24
10 hours ago Detected
battery level 0
heartbeat 89752342 (and counting)
child id 24
description: Kattenbak cycle teller
node id 3

In configuration.yaml I have this added:


initial: 0
step: 1

- device: ‘’
tcp_port: 5003
persistence_file: ‘mysensors.json’
version: ‘2.3’

In /config/sensors/kattenbak.yaml I have this:

  • platform: statistics
    entity_id: binary_sensor.catlitter_3_24

But now I am stuck :wink:
What I want is this, as soon as binary_sensor.catlitter_3_24 -> V TRIPPED status is changing from ON to OFF I want to have an increment action for kattenbak_cycle_counter:.

I hope somebody can help with an example ?
Would be great !

:wink: Arthur

from what I think I understand, V TRIPPED is an attribute to your sensor.
If that’s the case, and assuming its value can be returned with {{state_attr("binary_sensor.catlitter_3_24","v-tripped")}} <-- check the spelling/format/casing for v tripped
then you can create a template binary sensor:

  - platform: template
      cat_litter_tripped :
        friendly_name: "Cat Litter Tripped"
        value_template: '{{state_attr("binary_sensor.catlitter_3_24","v-tripped") == "on"}}'

again that’s assuming the attribute value is “on” (and not “On” or “ON”)

Thanks for your help, but that doesn’t work.

The sensor binary_sensor.catlitter_3_24 has fthe state ‘on’ when the CatLitterRobot is doing nothing. When it starts cleaning, the sensor’s state is changing from ‘on’ to ‘off’ and when it’s ready it’s ‘on’ again.

What I want is this: a counter which counts these cycles :wink:

I have the counter already:

initial: 0
step: 1

But how can I increment this kattenbak_cycle_counter as soon as the state of binary_sensor.catlitter_3_24 is changing ?

Any help would be great !

Create an automation that triggers on sensor changing to on and add a service that increments the counter. Check the doc dire automation and for counters there area examples to get you started

I have installed NODE-RED, in a few minutes it worked :wink:

NODE-RED code:

[{“id”:“6438e7d0.1ccf38”,“type”:“tab”,“label”:“Flow 2”,“disabled”:false,“info”:""},{“id”:“82c002b5.bda78”,“type”:“server-state-changed”,“z”:“6438e7d0.1ccf38”,“name”:“Kattenbak sensor”,“server”:“d4b3adf3.7a871”,“version”:1,“entityidfilter”:“binary_sensor.catlitter_3_24”,“entityidfiltertype”:“exact”,“outputinitially”:false,“state_type”:“str”,“haltifstate”:“off”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:2,“output_only_on_state_change”:true,“x”:110,“y”:120,“wires”:[[“4839ec97.1380b4”],[]]},{“id”:“4839ec97.1380b4”,“type”:“api-call-service”,“z”:“6438e7d0.1ccf38”,“name”:“Verhoog kattenbak cycle teller”,“server”:“d4b3adf3.7a871”,“version”:1,“service_domain”:“counter”,“service”:“increment”,“entityId”:“counter.kattenbak_cycle_counter”,“data”:"",“dataType”:“json”,“mergecontext”:"",“output_location”:"",“output_location_type”:“none”,“mustacheAltTags”:false,“x”:460,“y”:200,“wires”:[[]]},{“id”:“d4b3adf3.7a871”,“type”:“server”,“z”:"",“name”:“Home Assistant”}]

Maybe I am wrong, but it seems to be with NODE-RED you don’t need the HA-Automation at all…