Closed RolandWijnen closed 1 year ago
By the way, it is more stable and simpler to use REST API. My example: https://github.com/ALERTua/ha_pyscript_modules/blob/main/entities/uisp.py
@RolandWijnen could you please update or close the issue? Thank you
@ALERTua - thanks so much for reviewing and cleaning up old issues!
I'm working on a way to turn on and off my PoE ports on my Unifi switch. I found the script below, which works if I run it standalone.
`
`
However, when I add the @service tag and load it through the Services tab in Home Assistant and run it, like this:
it raises the following error:
Exception in line 19: tn.expect(expect, timeout) ^ TypeError: 'str' object does not support item assignment
I don't see the problem here. I suspect the 'interfaces' argument is causing problems here, because I do see a telnet session being started on the switch. Apparently, the 'expect' argument being passed, is a 'str' while it shoudl be a list. Not sure why that is happening when executing this in PyScript.
Any ideas what I'm overlooking? Much appreciated.