molobrakos / tellsticknet

Interface to a Tellstick Net device on the local network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem getting started

mannerydhe opened this issue · comments

Hi,
This looks awesome and I'd love getting it up and running.
Please tell me if I'm missing something.
I've compiled it using make under Linux. Everything checks out OK and I can properly discover my Tellsticknet on the network running the command python3 -m tellsticknet -vv discover
That's about it. I want to use it in conjunction with Home Assistanst using the mqtt option. However, I run into the following problems:

  1. Using the provided example configuration, the command python3 -m tellsticknet -vv devices throws the following error:
18-08-22 23:45.09 DEBUG (MainThread) [__main__] checking for config file /home/homeassistant/tellsticknet_api/tellsticknet/tellsticknet.conf
18-08-22 23:45.09 DEBUG (MainThread) [__main__] checking for config file /home/homeassistant/tellsticknet_api/tellsticknet/.tellsticknet.conf
18-08-22 23:45.09 DEBUG (MainThread) [__main__] checking for config file /home/homeassistant/tellsticknet.conf
- Door
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/homeassistant/tellsticknet_api/tellsticknet/__main__.py", line 162, in <module>
    for e in (e for e in read_config() if e['class'] == 'command'):
  File "/home/homeassistant/tellsticknet_api/tellsticknet/__main__.py", line 162, in <genexpr>
    for e in (e for e in read_config() if e['class'] == 'command'):
KeyError: 'class'

Commenting out the class setting nor deleting it resolves the issue.
2. Trying to turn on a light (using the house and unit from telldus live), python3 -m tellsticknet -vv send protocol=arctech model=selflearning house=5092673 unit=1 cmd=turnon throws the following error:

18-08-22 23:59.29 DEBUG (MainThread) [__main__] checking for config file /home/homeassistant/tellsticknet.conf
method not found

Doesn't matter if cmd=on, ON, turnon, turnoff etc. same result.

  1. Trying to connect to a local mqtt broker using python3 -m tellsticknet -vv mqtt with .config/mosquitto_pub containing the following information:
-h localhost
-p 1883
-username test
-pw test

results in the following error:

18-08-23 00:07.58 DEBUG (MainThread) [tellsticknet.mqtt] Connecting
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/homeassistant/tellsticknet_api/tellsticknet/__main__.py", line 208, in <module>
    run(config, host=host)
  File "/home/homeassistant/tellsticknet_api/tellsticknet/mqtt.py", line 574, in run
    port=int(credentials['port']))
  File "/usr/local/lib/python3.6/dist-packages/paho_mqtt-1.3.1-py3.6.egg/paho/mqtt/client.py", line 768, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.6/dist-packages/paho_mqtt-1.3.1-py3.6.egg/paho/mqtt/client.py", line 927, in reconnect
    sock.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer

I can sucessfully publish to the mqtt broker using Node-red.

I'm suspecting that I'm missing something crucial here since you've got it running just fine.

Looking forward to your response.

Happy to hear you want to use my code, thanks for testing and finding bugs!

  1. Is fixed here
  2. I noticed that I actually never implemented specifying params on the command line this way. Clarified it now. If you have a valid config file you should be able to do tellsticknet send livingroom on, tellsticknet send kitchen dim 50, etc.
  3. I believe this is because the code currently only supports connecting to the MQTT broker using SSL. I'm running my broker with SSL enabled on port 8883 and it works. So your options are to enable non-SSL in the client code (should not be to hard), or to enable SSL in your MQTT broker.

Thank you for the quick response! Are Nexa switches supported? Trying to turn on a Nexa switch using the device name throws an error about not finding "nexa.encode".
I can provide you a debug log when I get home.

Here is the log as promised:

18-08-23 20:35.09  INFO (MainThread) [tellsticknet.discovery] Discovering tellstick devices ...
18-08-23 20:35.09  INFO (MainThread) [tellsticknet.discovery] Found TellStickNet device with firmware 17 at 192.168.1.216
18-08-23 20:35.09 DEBUG (MainThread) [tellsticknet.controller] creating controller with address 192.168.1.216 (ACCA5400218D)
18-08-23 20:35.09 DEBUG (SenderThread) [tellsticknet.controller] Waiting for command forever
18-08-23 20:35.09 DEBUG (MainThread) [__main__] checking for config file /home/homeassistant/tellsticknet_api/tellsticknet/tellsticknet.conf
18-08-23 20:35.09 DEBUG (MainThread) [__main__] checking for config file /home/homeassistant/tellsticknet_api/tellsticknet/.tellsticknet.conf
18-08-23 20:35.09 DEBUG (MainThread) [__main__] checking for config file /home/homeassistant/tellsticknet.conf
18-08-23 20:35.09 DEBUG (MainThread) [tellsticknet.controller] Sending time 1
18-08-23 20:35.09 DEBUG (MainThread) [tellsticknet.protocol] Encoding for protocol nexa
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/homeassistant/tellsticknet_api/tellsticknet/__main__.py", line 203, in <module>
    controller.execute(device, method, param=param)
  File "/home/homeassistant/tellsticknet_api/tellsticknet/controller.py", line 135, in execute
    self._execute(device, method, param)
  File "/home/homeassistant/tellsticknet_api/tellsticknet/controller.py", line 115, in _execute
    packet = encode(**device, method=method, param=param)
  File "/home/homeassistant/tellsticknet_api/tellsticknet/protocol.py", line 314, in encode
    return protocol.encode(**device)
AttributeError: module 'tellsticknet.protocols.nexa' has no attribute 'encode'

Should python3 -m tellsticknet -vv listen generate something more than this?

18-08-23 20:37.59  INFO (MainThread) [tellsticknet.discovery] Discovering tellstick devices ...
18-08-23 20:37.59  INFO (MainThread) [tellsticknet.discovery] Found TellStickNet device with firmware 17 at 192.168.1.216
18-08-23 20:37.59 DEBUG (MainThread) [tellsticknet.controller] creating controller with address 192.168.1.216 (ACCA5400218D)
18-08-23 20:37.59 DEBUG (SenderThread) [tellsticknet.controller] Waiting for command forever
18-08-23 20:37.59 DEBUG (MainThread) [tellsticknet.controller] Listening for signals from 192.168.1.216
18-08-23 20:37.59  INFO (MainThread) [tellsticknet.controller] Registering self as listener for device at 192.168.1.216
18-08-23 20:37.59 DEBUG (MainThread) [tellsticknet.controller] Sending packet to controller 192.168.1.216:42314 <b'B:reglistener'>

Have you specified protocol, model, house, unit in tellsticknet.conf?
Like:

controller: abc123
name: Sovrum
component: light
protocol: arctech
model: selflearning
unit: 15
house: 45213512
---
... etc

You can find out what parameters to use by starting tellsticknet -vv listen and then start pressing buttons on your Nexa controller. Then you should get decoded packets displayed in the console with relevant parameters. You should probably have arctech instead of nexa in your config.

(btw feel free to contribute better documentation for the next guy) :-)

Great! I got it working with one of my Nexa switches. The one I got working is just a regular power outlet. I've got another Nexa device supposed to be mounted behind a regular wall switch which doesn't work. It's called "self-learning Pro" in Telldus live. Any idea?
Have you tried Jula's Anslut?
Sorry for all the questions. When I get the time I'll try to sniff out the packages sent from Telldus live to the Tellstick and compare them.

Ok, I ended up programming it myself using Node-red. Analysing the packages sent using tcpdump I found that Nexa Pro and Julia are the same and very similar to Nexa (built-in arctech). The Nexa (arctech) house code is 26 bits and Jula's/Nexa Pro are 26 bits and has to end in 10. Telldus live had a problem early on where Jula's Anslut wouldn't work if you didn't pick a house code which ended in 10(binary). It seems like if the house code doesn't end correctly it just zero pads it to 24 bits and adds 10 to the end of it, making it 26 bits.

Closing for now. Feel free to provide suggestions for changes as PRs.