My project is to know if my trash bin is in the garage or not.
I am using a VL53L0X distance sensor in ESPHome. Automations in Home Assistant turn on or off a toggle helper:
alias: trashbin-present
description: Turns on a boolean helper if the trashbin distance is within one meter
trigger:
- platform: numeric_state
entity_id: sensor.trashbin
above: 0
condition: []
action:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.trashbin_present
mode: single
In node-red I am using the Current State node to read this boolean toggle every second.
The first output is if the conditions are true. The second is if false.
Say you have ‘If State’ is True ‘For’ 2 minutes. It that condition matches the flow goes to first output. Otherwise the flow goes to the second output. It’s useful if you’d like to take an action in either case.
Also instead of using a 1 second timer for checking the Current State you could just use one node, The Event State node. It will start the flow whenever a change in the boolean is detected.
Are you sure you used ‘input_boolean.trashbin_present’ as the entityID? it should return True or False (1 or 0).
If you used ‘sensor.trashbin’ as the entityID I can see where a number and not a boolean could be returned based on the distance of the can.
Thanks for the input.
The ‘input_boolean.trashbin_present’ is the result of testing sensor.trashbin.
In home assistant:
The actual sensor is an ESPHome device that returns a distance or “unknown”.
Automations in Home Assistant detect if the bin is in-place or missing.
The “present” automation turns ON the input.boolean.trashbin_present if the sensor is sending a number >=0.
The “missing” automation turns OFF the helper: input.boolean.trashbin_present if the sensor is sending “unknown”
in Node Red:
The current state node tests the input.boolean.trashbin_present entity. It is either ON or OFF.
Next, a Change Node turns ON/OFF to TRUE/FALSE. The output (TRUE or FALSE) turns on or off the Blinker Node.
After the Blinker Node, a switch alternates between MQTT codes for Black Text on a yellow background, or White on Black.
If the Current State Node is OFF, then the MQTT code for the default foreground/background colors.
The 1-second delay is to wait for the blinker to stop.