I’ve been using an input_boolean
helper to indicate whether my trash can is on the curb or not. It has an NFC tag which flips the bit to on.
Due to some confusion, my can got mixed up with a neighbors. Since the NFC tag hidden, it’s not easy to tell which one belongs to which neighbor, unless you know the can’s barcode. I realize that in a normal situation, these cans are fungible: My neighbor getting my recycling can and me getting theirs is not that big of an issue.
Since I don’t want to tag yet another can, I figured I’d add an attribute with the can’s barcode and then make sure I have the correct can.
I found this topic but I don’t want to download a script for this. The OP made it sound like a template with a binary sensor might do the trick. I started setting it up but then discovered that the automation service input_boolean.turn_on
can’t “turn on” the binary sensor’s state.
Here is my template:
- unique_id: b5064b8bff9e42c3944c55caecd93e52
binary_sensor:
- name: Recycling Can 7890
unique_id: '5c619b9e-9234-43a0-ba39-d139336f7983'
state: 0
attributes:
barcode: "1234567890"
And here’s my automation:
- id: '20f2f708-f7f6-4673-82cf-de7b9f0a891c'
alias: Test Tag 1 is scanned
trigger:
- platform: tag
tag_id: de196629-0dac-45e0-8863-57e91fa0df5f
condition: []
action:
- service: input_boolean.turn_on
data: {}
target:
entity_id: binary_sensor.recycling_can_7890
mode: single
My guess is that sensor states aren’t designed to be changed via automation; they are designed to be read. Is this correct?
If that’s the case, should the template be updated to read the input_boolean.recycling_can
state? Or is there a way to interact with the entity and flip the binary state using automation?
Thanks!