smar000 / evoGateway

Python script for listening in and responding to evohome heating control radio messages
47 stars 17 forks source link

How to install #5

Closed Maikel-K closed 4 years ago

Maikel-K commented 4 years ago

Smar000,

How do we set this all up correctly? I have solder the wires to the CC1101 and connected it to the Nano V3.

Whats next? Im havent worked with Arduino's much so im really in need of some step by step guides.

Thanks!

smar000 commented 4 years ago

Unfortunately I do not have the time to write a beginner's guide, particularly as there are too many possible variations in each user's set up. However, the broad steps you need to take are:

  1. Install the correct firmware on the Arduino (link in the main README page).

  2. Set the evogateway.cfg parameters, especially the USB port number etc.

  3. Run the main evogateway.py script with python.

That's it!

If you are using Ubuntu, to install the firmware you need to install avrdude, gcc-avr and avr-libc, e.g.: sudo apt install avrdude sudo apt install gcc-avr sudo apt install avr-libc

Then run the make command to compile everything. Once this is successfully done, you can upload the firmware to the Arduino with something like:

avrdude -p atmega328p -P/dev/ttyUSB0 -c arduino -b 57600 -U flash:w:evo.elf

making sure to change the port and the name of the compiled elf file.

Maikel-K commented 4 years ago

So do I Need this link: The firmware I am running is one modded by ghoti57 available from https://github.com/ghoti57/evofw2,

Or: https://github.com/smar000/evofw2

Thanks for the quick reply!

smar000 commented 4 years ago

Use the one from ghoti57 - https://github.com/ghoti57/evofw2 (the fork in my repo was when I was experimenting). Remember to use the FIFO branch.

Maikel-K commented 4 years ago

thanks, downloaded the FIFO branch, compiled it (for other readers: copy files of the FIFO zip to your RPI, use cd to navigate to the folder and type make. It shoud compile the files)

And used your avrdude command with changed baud of 57600 to 115200. avrdude -p atmega328p -P/dev/ttyUSB0 -c arduino -b 115200 -U flash:w:evo.elf -v

With the baud of 57600 i was getting following errors: avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

I installed musquito MQTT just to get rid of the MQTT error if it wasnt installed. This is my MQTT part of the CFG file: MQTT_PUB_TOPIC = evohome/gateway MQTT_SUB_TOPIC = evohome/gateway/command MQTT_SERVER = 192.168.1.104 MQTT_USER = openhab MQTT_PW = xxxx MQTT_CLIENTID = evoGateway

I only changed the IP adress and the error was gone, i still have to figure out how MQTT is working but i was just hoping to see some data getting shown but it's not showing.

When i run the evogateway.py file the only thing im seeing is: pi@raspberrypi:~/evohome $ python evogateway.py 2019-10-22 22:53:20 | | | evohome Listener/Sender Gateway version 1.9.5 2019-10-22 22:53:20 | | * | 1: Connected to serial port /dev/ttyUSB0 2019-10-22 22:53:20 | | | 2019-10-22 22:53:20 | | | ----------------------------------------------------------- 2019-10-22 22:53:20 | | | Devices loaded from 'devices.json' file: 2019-10-22 22:53:20 | | | 01:111111 - Living Room - Zone 1 [Master] 2019-10-22 22:53:20 | | | 30:071715 - EvoGateway - Zone 240 [Master] 2019-10-22 22:53:20 | | | ----------------------------------------------------------- 2019-10-22 22:53:20 | | | 2019-10-22 22:53:20 | | | Listening... 2019-10-22 22:53:20 | | * | Connecting to mqtt server 192.168.1.104 2019-10-22 22:53:20 | | * | Subscribing to mqtt topic 'evohome/gateway/command' 2019-10-22 22:53:21 | | * | MQTT connection established with broker

Maikel-K commented 4 years ago

Tried it again this morning and got something but dont know what it means.... it's an error: 2019-10-23 07:50:02 | | ERROR | Pattern match failed on received data: '--- ýüþþþþÿþþþþýüþþþþÿþþþþýüþþþþÿþþþþþýüþþþþÿþþþþþýõýüþþþþÿþþþþþþýüþþþþÿþþþþýþüüéXùá…ˆýø˜' (port: 1) 2019-10-23 07:50:43 | | ERROR | Pattern match failed on received data: '--- ýüþþþþÿþþþþÎþýüþþþþÿþþþþþþýüþþþþÿþþþþýüþþþþÿþþþþýüþþþþÿþþþþýüþþþþÿþþþþþýüþþþþÿþþþþþýõýüþþþþÿþþþþþþ' (port: 1) And when i closed the connection with CTRL+C this came; ^C2019-10-23 07:54:21 Tidying up and exiting... Closing port '/dev/ttyUSB0' Traceback (most recent call last): File "evogateway.py", line 1394, in <module> data_row = serial_port.readline().strip() File "/home/pi/.local/lib/python2.7/site-packages/serial/serialposix.py", line 483, in read ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left()) TypeError: argument must be an int, or have a fileno() method. Exception in thread Thread-1 (most likely raised during interpreter shutdown): Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner File "/usr/lib/python2.7/threading.py", line 754, in run File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2913, in _thread_main File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1578, in loop_forever File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1092, in loop File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1429, in loop_misc <type 'exceptions.TypeError'>: 'NoneType' object is not callable

smar000 commented 4 years ago

Looks like your baud rate setting is incorrect. You need to make sure that the setting in the .cfg files matches what you actually have the physical port set at at the OS level. You can check the current setting by: stty -F /dev/ttyUSB0 speed

and set the required OS level speed by: stty -F /dev/ttyUSB0 speed 115200

etc

Maikel-K commented 4 years ago

I checked the speed: pi@raspberrypi:~/evohome $ stty -F /dev/ttyUSB0 speed 2400

When trying to set it and check it again, it's the speed i have set a few times, then it changes back to 2400... any clue? pi@raspberrypi:~/evohome $ stty -F /dev/ttyUSB0 115200 pi@raspberrypi:~/evohome $ stty -F /dev/ttyUSB0 speed 115200 pi@raspberrypi:~/evohome $ stty -F /dev/ttyUSB0 speed 115200 pi@raspberrypi:~/evohome $ stty -F /dev/ttyUSB0 speed 2400 pi@raspberrypi:~/evohome $ `

Maikel-K commented 4 years ago

Strange.. i changed the baud rate in the evohome.cfg again to 115200 and started the script. Inmediattly the following appeared: 2019-10-24 22:43:57 | | | evohome Listener/Sender Gateway version 1.9.5 2019-10-24 22:43:57 | | * | 1: Connected to serial port /dev/ttyUSB0 2019-10-24 22:43:57 | | | 2019-10-24 22:43:57 | | | ----------------------------------------------------------- 2019-10-24 22:43:57 | | | Devices loaded from 'devices.json' file: 2019-10-24 22:43:57 | | | 01:046829 - EvoGateway - Zone 240 [Master] 2019-10-24 22:43:57 | | | 01:111111 - Living Room - Zone 1 [Master] 2019-10-24 22:43:57 | | | ----------------------------------------------------------- 2019-10-24 22:43:57 | | | 2019-10-24 22:43:57 | | | Listening... 2019-10-24 22:43:57 | | * | Connecting to mqtt server 192.168.1.104 2019-10-24 22:43:57 | | * | Subscribing to mqtt topic 'evohome/gateway/command' 2019-10-24 22:43:58 | | * | MQTT connection established with broker 2019-10-24 22:43:58 | | NEW DEVICE FOUND | 30:134878 2019-10-24 22:43:58 |1| ACTUATOR_STATE | RQ| 30:134878 -> 63:262143 | State update request 2019-10-24 22:44:01 |1| ACTUATOR_STATE | RQ| GWAY 30:134878 -> 63:262143 | State update request 2019-10-24 22:45:48 | | ERROR | Pattern match failed on received data: '--- ýüþþþþÿþþþþÎþüøüÐXñ‹ÿìÚ›5°[óýüþþþþÿþþþþþþýüþþþþÿþþþþð"ûüé_ûáøØÒ“' (port: 1)

A start and stop of the script issued the following: 2019-10-24 22:49:26 | | | evohome Listener/Sender Gateway version 1.9.5 2019-10-24 22:49:26 | | * | 1: Connected to serial port /dev/ttyUSB0 2019-10-24 22:49:26 | | | 2019-10-24 22:49:26 | | | ----------------------------------------------------------- 2019-10-24 22:49:26 | | | Devices loaded from 'devices.json' file: 2019-10-24 22:49:26 | | | 01:046829 - EvoGateway - Zone 240 [Master] 2019-10-24 22:49:26 | | | 01:111111 - Living Room - Zone 1 [Master] 2019-10-24 22:49:26 | | | ----------------------------------------------------------- 2019-10-24 22:49:26 | | | 2019-10-24 22:49:26 | | | Listening... 2019-10-24 22:49:26 | | * | Connecting to mqtt server 192.168.1.104 2019-10-24 22:49:26 | | * | Subscribing to mqtt topic 'evohome/gateway/command' 2019-10-24 22:49:26 | | * | MQTT connection established with broker 2019-10-24 22:49:28 | | NEW DEVICE FOUND | 04:048531 2019-10-24 22:49:28 | | ERROR | ''zoneId'' on line 563 [Command BATTERY_INFO, data: '--- I --- 04:048531 --:------ 01:046829 1060 003 026401', port: 1] 2019-10-24 22:49:28 | | ERROR | ''zoneId'' on line 563 [Command BATTERY_INFO, data: '--- I --- 04:048531 --:------ 04:048531 1060 003 006401', port: 1] 2019-10-24 22:49:28 |1| WINDOW_STATUS | I | TRV 04:048531 -> CONTROLLER | CLOSED [Zone 3 ] 2019-10-24 22:49:28 | | ERROR | '3' on line 563 [Command WINDOW_STATUS, data: '--- I --- 04:048531 --:------ 01:046829 12B0 003 020000', port: 1] 2019-10-24 22:49:29 | | NEW DEVICE FOUND | 30:134878 2019-10-24 22:49:29 | | CONTROLLER_MODE | Invalid payload length of 1 (should be 8). Raw msg: --- RQ --- 30:134878 01:046829 --:------ 2E04 001 FF 2019-10-24 22:49:29 |1| CONTROLLER_MODE | RP| CTL EvoGateway -> GWAY 30:134878 | Auto mode 2019-10-24 22:49:30 | | OTHER_COMMAND | --- RQ --- 04:048531 01:046829 --:------ 0100 005 006E6CFFFF 2019-10-24 22:49:30 | | OTHER_COMMAND | --- RP --- 01:046829 04:048531 --:------ 0100 005 006E6CFFFF 2019-10-24 22:49:32 | | ERROR | ''zoneId'' on line 563 [Command BATTERY_INFO, data: '--- I --- 04:048531 --:------ 01:046829 1060 003 026401', port: 1] 2019-10-24 22:49:32 | | ERROR | ''zoneId'' on line 563 [Command BATTERY_INFO, data: '--- I --- 04:048531 --:------ 04:048531 1060 003 006401', port: 1] 2019-10-24 22:49:32 |1| ACTUATOR_STATE | RQ| GWAY 30:134878 -> 63:262143 | State update request

So stuff seems to be happening.... but also issues errors?

smar000 commented 4 years ago

Your devices.json file does not appear to be correctly set up. You need to make sure you have ALL your devices specified, with the CORRECT zone numbers.

Maikel-K commented 4 years ago

How do we find this information?

smar000 commented 4 years ago

The devices_new.json file should list all the devices that are 'heard' by the system whilst it is listening in on the evohome radio communications. You can use this as a basis to help with setting up your own devices.json file. Remember to ensure you have the zoneMaster flag set correctly for the device that is the master in a multi-device zone.

Maikel-K commented 4 years ago

It only registered 3 devices...

What i do see happening is that in evogatway.log a lot is going one which seems to be recieved but not correctly interperted: 2019-10-26 22:28:47: 1: úü 2019-10-26 22:28:50: 1: ÷ü 2019-10-26 22:28:52: 1: ý 2019-10-26 22:29:08: 1: Ûþò 2019-10-26 22:29:38: 1: VþÒö 2019-10-26 22:29:41: 1: â 2019-10-26 22:29:45: 1: óù 2019-10-26 22:29:47: 1: ý 2019-10-26 22:30:39: 1: óù 2019-10-26 22:30:41: 1: ’ü 2019-10-26 22:30:43: 1: ý 2019-10-26 22:31:01: 1: üç 2019-10-26 22:31:32: 1: ý 2019-10-26 22:31:36: 1: ý 2019-10-26 22:31:40: 1: ÿ 2019-10-26 22:32:17: 1: Òþ 2019-10-26 22:32:18: 1: –úÿ²²ÿ 2019-10-26 22:32:20: 1: öaÿ 2019-10-26 22:32:30: 1: úþ 2019-10-26 22:32:32: 1: ò 2019-10-26 22:32:34: 1: úþ 2019-10-26 22:32:52: 1: ·ùò 2019-10-26 22:33:25: 1: òþ 2019-10-26 22:33:29: 1: § 2019-10-26 22:33:52: 1: üË 2019-10-26 22:33:53: 1: Ö 2019-10-26 22:34:09: 1: šþ÷›ÿ 2019-10-26 22:34:18: 1: òþ 2019-10-26 22:34:21: 1: òý 2019-10-26 22:34:47: 1: ýö 2019-10-26 22:34:53: 1: ÿ3 2019-10-26 22:34:59: 1: ÿ’Û 2019-10-26 22:35:03: 1: šÿò 2019-10-26 22:35:13: 1: šþö’ 2019-10-26 22:35:16: 1: Ò 2019-10-26 22:35:18: 1: òþšùþù–ÿò’ 2019-10-26 22:35:21: 1: [öÚ¿ 2019-10-26 22:35:24: 1: ÷ÿ 2019-10-26 22:35:28: 1: òò² 2019-10-26 22:35:31: 1: šùÚ² 2019-10-26 22:35:38: 1: úVŸò 2019-10-26 22:35:43: 1: òýÒû 2019-10-26 22:35:46: 1: ’ø–ÿ¶ 2019-10-26 22:35:48: 1: ç› 2019-10-26 22:35:50: 1: ãÿ 2019-10-26 22:35:58: 1: òýòó 2019-10-26 22:36:08: 1: úýÚâ 2019-10-26 22:36:09: 1: óü 2019-10-26 22:36:12: 1: òþ 2019-10-26 22:36:15: 1: þòùòã 2019-10-26 22:36:22: 1: ýÒû 2019-10-26 22:36:30: 1: òý’ 2019-10-26 22:36:37: 1: ú÷ñ 2019-10-26 22:36:38: 1: óþù 2019-10-26 22:37:13: 1: Û 2019-10-26 22:37:35: 1: úþ 2019-10-26 22:37:39: 1: ÷çž–· 2019-10-26 22:37:41: 1: öü» 2019-10-26 22:37:46: 1: ü² 2019-10-26 22:37:53: 1: “þç 2019-10-26 22:37:58: 1: ý³ 2019-10-26 22:38:33: 1: ³üšó 2019-10-26 22:39:27: 1: ýòþ 2019-10-26 22:39:59: 1: ’þ 2019-10-26 22:40:20: 1: Òÿö’ò“þ 2019-10-26 22:40:23: 1: ¿ÿ 2019-10-26 22:40:40: 1: Òéÿ 2019-10-26 22:41:21: 1: ’ÿÿ¾ÿ 2019-10-26 22:41:23: 1: úù 2019-10-26 22:41:29: 1: šÿ 2019-10-26 22:42:09: 1: Ò÷ 2019-10-26 22:42:16: 1: ³ùöÿ 2019-10-26 22:42:18: 1: ü 2019-10-26 22:42:20: 1: ü 2019-10-26 22:42:22: 1: žÿ 2019-10-26 22:43:00: 1: –’Ö 2019-10-26 22:43:11: 1: žþ 2019-10-26 22:43:13: 1: §—ÿ 2019-10-26 22:43:16: 1: ÿ 2019-10-26 22:43:50: 1: [ 2019-10-26 22:44:02: 1: þ 2019-10-26 22:44:05: 1: òþ 2019-10-26 22:44:09: 1: Òþ’ÿ 2019-10-26 22:44:11: 1: ÷÷›òþ Im playing around with baudrates but it seems that 115200 gives the most readable data but it's all hit and miss which i dont understand why.

smar000 commented 4 years ago

I have had my systems receiving fine on all standard baud rates from 56k to 256k. I suspect there is some underlying hardware issue with your set up. Could be anything, including the usb serial controller on your Arduino, the serial port on your PC etc.

Actually I just saw in one of your error logs that you are using a raspberry pi. I think I recall reading somewhere about issues with serial communications with the built-in USB. Maybe this is something for you to look at as well.

I'm sorry, but I don't think I can help further on this. All I can tell you is that the system has been fine in my home and in that of a number of other users.

Maikel-K commented 4 years ago

I did some checking of the wiring and hope it's better now. Started to execute the script again and all of a sudden this come: Traceback (most recent call last): File "/home/pi/evohome/evogateway.py", line 1362, in <module> initialise_mqtt_client(mqtt_client) File "/home/pi/evohome/evogateway.py", line 370, in initialise_mqtt_client mqtt_client.connect(MQTT_SERVER, port=1883, keepalive=0, bind_address="") File "/home/pi/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 838, in connect self.connect_async(host, port, keepalive, bind_address) File "/home/pi/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 893, in connect_async raise ValueError('Invalid host.') ValueError: Invalid host.

I didnt changed anything and cant find an solution for this. Tried a lot of settings but no solution.

EDIT: Well, the only thing i changed was starting to run the script as followes: python /home/pi/evohome/evogateway.py

That doesnt seem to work....

smar000 commented 4 years ago

The error message says that you do not have an address set for the mqtt server.

Maikel-K commented 4 years ago

Is it possible to check if the usb driver is causing an issue or something? I have the idea the port closes for some reason and stops working. This is an error message log from Domoticz. 2019-10-28 18:58:49.737 Status: evohome serial: Opening serial port: /dev/ttyUSB0@38400 2019-10-28 18:58:55.741 Status: evohome serial: serial setup retry in 30 seconds... 2019-10-28 18:58:55.207 Error: Serial Port closed!... Error: End of file

smar000 commented 4 years ago

Unfortunately I'm not really the best person to help you with debugging usb driver issues on your rpi. My installation is on an Ubuntu VM and so I have no experience of rpi usb issues.

Given that there doesn't appear to be a problem with the evogateway script itself, I'll close this thread now. If however you do find a problem with the script, don't hestiate to open a new issue.