Hallo everybody,
I personally developed for my home several custom Arduino (ATMega328) based nodes all of them communicating via Can-Bus shields. All this is now up and running many years now.
There’s also a node that is connected to HA (running on Raspberry) via Serial Port and I already figured out a very basic way to make HA control my system. This is working like charm and I’m copy-pasting my configuration to make my work available to everybody.
What I’m missing is HA reading back constantly the serial port to detect when a state changes. And I need your help to find the best way! Or any way to do it!
Some lines from my “configuration.yaml” file:
automation:
- alias: run_set_bedroom_light
trigger:
platform: state
entity_id: input_number.slider_bedroom_light
action:
service: >
{% if states('input_number.slider_bedroom_light') | int == 0 %}
shell_command.set_bedroom_light_to_one
{% elif states('input_number.slider_bedroom_light') | int == 1 %}
shell_command.set_bedroom_light_to_two
{% elif states('input_number.slider_bedroom_light') | int == 2 %}
shell_command.set_bedroom_light_to_three
{% elif states('input_number.slider_bedroom_light') | int == 3 %}
shell_command.set_bedroom_light_to_four
{% else %}
shell_command.set_bedroom_light_to_five
{% endif %}
shell_command:
set_bedroom_light_to_one: 'echo "023001\n" > /dev/ttyS0'
set_bedroom_light_to_two: 'echo "023002\n" > /dev/ttyS0'
set_bedroom_light_to_three: 'echo "023003\n" > /dev/ttyS0'
set_bedroom_light_to_four: 'echo "023004\n" > /dev/ttyS0'
set_bedroom_light_to_five: 'echo "023005\n" > /dev/ttyS0'
switch:
- platform: command_line
switches:
kitchen_light:
friendly_name: Kitchen light
command_on: 'echo "022002\n" > /dev/ttyS0'
command_off: 'echo "022001\n" > /dev/ttyS0'
cover:
- platform: command_line
covers:
livingroom_blind:
friendly_name: Livingroom blind
command_open: 'echo "011002\n" > /dev/ttyS0'
command_close: 'echo "011001\n" > /dev/ttyS0'
command_stop: 'echo "011003\n" > /dev/ttyS0'
Explanation: home assistant sends two numbers in 6 digits: first 3 digits are the node number, second 3 digits are the new state.
Example: Node number 23 is bedroom light, the state of the light goes from 1 (off) to 5 (max intensity)
Same 6 digits are being received on tty when the state of the light changes, but I don’t know how to read it and to apply to the switch, cover, …
Looking forward to reading some suggestions! Thank you in advance!