Fantastic! Do you have some news? Or can you point me to make it working as phyton script? Thank you so much!
I confirm that the script works correctly from CLI but I’m not able to go on, completely dummy.
Waiting for your help to create some kind of integration.
Thanks again!
Nobody that can help me to control this onboard leds?
Thanks!
I just implemented this:
- A script that can be called from Developer > Services and therefore also from automations, etc.
- The script calls a shell command which calls a python command. Can be simplified to calling the python script.
- The python script that worked for me is at Mini PC T9Plus RGB LED Control Program [rigacci.org] . I tried several other methods which did not end up working.
Beyond logical protocol/packets to send, the baud rate is important (it has to be 10000, 9600 does not work) and the delay between sending bytes (it should be 5 ms - 0 is not ok).
Script:
alias: Update T9 LEDs
sequence:
- action: shell_command.t9leds
data:
mode: "{{ mode }}"
brightness: "{{ brightness }}"
speed: "{{ speed }}"
fields:
mode:
description: The mode to set (off, auto, rainbow, breathing, colourcycle)
example: rainbow
selector:
select:
options:
- "off"
- auto
- rainbow
- breathing
- colourcycle
required: true
brightness:
description: The brightness level (1-5)
example: 3
selector:
number:
min: 1
max: 5
required: true
speed:
description: The speed level (1-5)
example: 2
selector:
number:
min: 1
max: 5
required: true
description: Update T9 LEDs
icon: mdi:led-strip
In the ha configuration:
shell_command:
t9leds: './leds.py -m {{ mode }} -b {{ brightness }} -s {{ speed }}'
And I have leds.py
located in the config
directory. I have the executeable bit set (chmod +x leds.py
from the terminal).
There are surely other ways to make this work.
This is an example of a service call:
action: script.name_of_script
data:
mode: "off"
brightness: 1
speed: 5
My setup here is the following: proxmox installed on an Adler Lake N95 mini-PC which is said to be a T9Plus type, and a Qemu VM that runs HAOS where I added the USB map for the internal serial port. Before mapping, one can test the script on the proxmox host, but you need to add python3-serial
as a package.
If you want to run in from the ha terminal, you need py3-pyserial
(I guess that will install python). But I do not think that you need to install that if you run the script with the shell_command
.
Thank you! I’ll try as soon I’m in front of my mini pc.
Thanks again, any other suggestion is appreciated!
It’s not clear for me wich scripts to use and where place them… both of them (one in the link and one you posted) both in /config/ directory? (I’m using HAOS installed directly on the mini pc)
Thanks again!
My UI is in French so translating back to english:
The script goes under “Automations & scenes > Scripts” where you need to add a new script, go to yaml mode (bottom of screen) and paste the script.
The second yaml extract is something you need to add to configuration.yaml.
configuration.yaml is located in /homeassistant - that is where I put the leds.py script you can copy paste from the provided link. You need to make it executable (chmod +x leds.py) as far as I know - it’s also why the configuration shows “./leds.py”.
If you do not know how to make a file executable, you can replace “./leds.py” with “python3 ./leds.py”.
You can call the HA script from Developer Tools > Services (or Actions, it seems to be renamed).
Thank you so much! With your advices it’s working perfectly!!!
Now I’ll try to make a custom component to manage alerts with visual leds
I noticed that the script no longer works even though the configurations have remained the same. Could it be due to some Home Assistant update? From what I see the script runs correctly but does not “pass” the information to the hardware and the LEDs do not change state. Do you have any suggestions? Thanks!
I suggest to check the “hardware”.
My UI in french - click “Tout le matériel”.
I have one system where I do not manage the leds in HA (I run HA on proxmox):
On the other one, I have the script, but I can’t find /dev/ttyUSB0 - possibly because I did not manage it in HA after all on that system.
lsusb on the proxmox host shows me:
Bus 001 Device 002: ID 0bda:b85b Realtek Semiconductor Corp. Bluetooth Radio
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 1a86:7523 QinHeng Electronics CH340 serial converter
And we can see that looking up 0bda gives the path tot the device.
For my zigbee stick, I get, showing that it is at /dev/ttyACM0:
So by checking your hardware as seen by HA, you can check if it is found, and where it is mapped.
I did not map the leds (1a86), so I can not show it.
My main interest was to shutdown the leds, I have not found any use for anything else. So I did that on proxmox directly.
Thank you so much!
But I can’t explain why the script worked good till something happened, maybe an Homeassistant update that reverted back pyserial access to USB0
Device mappings are subject to change on restart, and the script uses a default of /dev/ttyUSB0
which makes this possibility likely to occur.
People who use zigbee over USB are extremely familiar with this - one day their coordinator will be recognised as /dev/ttyACM0
, and after a restart it will be recognised as /dev/ttyACM1
(probably because some other serial device was plugged in between restarts and claimed the original address).
This explains how you can find it. If you do manage, it should be pretty easy to use that path as the default in your script or by explicitly defining it as a parameter.