Replies: 2 comments 1 reply
-
You're entering in to the realm of things that pyscript doesn't really make any easier than a regular integration, as, I imagine, ideally, these would be in the With that being said, you can use The trickiest part will be, I assume, that both read and writing need to happen on the same device, and I don't think you can have two processes accessing the same device file. So... you're likely going to want to do this in one "script" so that you can read constantly and write when needed. Additionally, you'll, ideally, want to find a library that can open the device in a non-blocking way and use a callback when new data is available. This way, it can run within Home Assistant's event loop. Good luck. And be sure to share the final result with us! |
Beta Was this translation helpful? Give feedback.
-
https://hacs-pyscript.readthedocs.io/en/stable/reference.html#service-service-name |
Beta Was this translation helpful? Give feedback.
-
Hi, complete newbie, installed pyscript tonight, point me in the right direction, and go easy please!
I have a Python scrpt that talks via a USB dongle to a rs485 / modbus network, to an 8CH relay, with a script to switch a relay on/off, and another script to read if it did happen. I registered an app in pyscript, I think the modbus_read and modbus_write shold be seperate apps, but not sure yet, could possibly be combined - if I can write a variable to the .py that first sends a command for a CH to be switched on/off, and then read the USB port, but not that far yet. (Right now I have .py for writing, and another for reading which works). Currently the read python script runs contiously - and reports back the state if any write happened.
I guess I need to register an entity_id in HASS, where the state of the modbus device register is populated into. I am unclear which of this would be a @state_trigger, or @service, and do not find examples. Could someone point me in the right direction please?
Beta Was this translation helpful? Give feedback.
All reactions