rjblake / remeha

Connect ESP8266 directly to Remeha CV/Boiler to read data using PHP
28 stars 13 forks source link

Remeha Avanta V1 P3 #8

Closed juanelc closed 4 years ago

juanelc commented 5 years ago

Hello Richard,

Thank you for making these scripts available. I used your script and excel sheet to readout my AvantaV1P3. First I checked the requests and responses. There are a few differences for which I had to make some adjustments:

attached are the ini file (adjusted requests, and added some parameters), remeha-functions (added checksum), remeha-counters.php and remeha-samples.php. I also added the excelsheet updated with the Avanta V1 p3.

I use cronjobs to execute both scripts (samples every minute, counters every hour)

I tried to keep the script compatible with the Calenta (by setting the ini values), so it could be added to your work.

XML Mapping-Remeha AvantaV1-P3.xlsx

remehaAvantaV1P3.zip

Best regards,

Johan

rjblake commented 5 years ago

Johan - many thanks for this. I have not had time to review, but will hopefully get around to incorporating in the master with an added parameter for users to choose between a Calenta or Avanta to keep a single master. I keep the scripts running in an endless loop (using pm2) and use the 'sleeptime' and 'sample_loops' parameter to set the frequency of collection. I'm not sure if you changed the code to avoid additional jobs to start each time you run the cronjob

JustinHoeky commented 5 years ago

Hi @rjblake ,

I also have the Avanta V1 (P3) and would like to use this. Could we team up and try to make this work?

Once it's working i want to try and make it work in Domoticz/HomeAssistant

Best regards, Justin

rjblake commented 5 years ago

Justin - I have almost no time at present to do anything on this. Check the files/work from Johan in the .zip - he has got same boiler and working. I will incorporate this into the master at some time; just not sure when. Feel free to do this if needed and create a request to merge later

JustinHoeky commented 5 years ago

I missed to whole point that he got it working, sorry. Just ordered a Adafruit so will try it next week on my Domoticz instance if all my other parts arrive.

If it's all working i will create a merge request.

Thanks!

JustinHoeky commented 5 years ago

@rjblake just received my Adafruit HUZZAH and tried to flash. Gave up for now, after 2 hours, since i can't get it flashed with Windows.

Any idea how to make the ESP-LINK flashing easier?

JustinHoeky commented 5 years ago

@rjblake ignore my previous post, i got it working. Stupid me was working on 3.3v instead of 5v.

@juanelc could you help me out a bit? I'm getting CRC errors once i use your files.

juanelc commented 5 years ago

Hi Justin,

For me it works with the attached files and cronjobs, but not very stable.

about the CRC, it should do a checksum8xor instead of a CRC. Did you set the ini file correctly?

remeha_crc = 2; #4 for Calenta, 2 for Avanta

JustinHoeky commented 5 years ago

Hi @juanelc

Thanks you for the info about the power, i also powered it externally now.

I copied your files and written these over the original ones. CRC is indeed on 2, but for some reason it still tries to CRC.

My RPI 3b+ is running the webfiles, and has the following:

remeha_sample_length = 128;         #148 for Calenta, 128 for Avanta
remeha_counter_length = 48;     #52 for Calenta, 48 for Avanta
remeha_sample_req_length = 8;       #10 for Calenta, 8 for Avanata
remeha_crc = 2;             #4 for Calenta, 2 for Avanta
remeha_header = 5;          #6 for Calenta, 5 for Avanta
counter_offset = 6;         #0 for Calenta, 6 for Avanta

Will try to swap RX and TX tommorow, but i'm almost sure that's not gonna solve it.

Can you post your remeha.php (or all files)? I do see this in my file, not sure if that's the issue?

// Time to 'Work the SAMPLE Data'
//
function sample_data_dump($data_sample, $echo_flag, $newline)
    {
    // Manipulate data & Do a CRC Check 
    $decode = str_split($data_sample, 2);
    $hexstr = str_split($data_sample, 148);
    $hexstrPayload = substr($data_sample, 2, 140);
    $hexstrCRC = substr($data_sample, 142, 4);
    $crcCalc = crc16_modbus($hexstrPayload);
JustinHoeky commented 5 years ago

Hi juanelc,

Could you send me a photo of how you connected it with the Power supply and the Avanta?

Just want to make sure i'm doing it correctly.

Kind regards, Justin

juanelc commented 5 years ago

I only use remeha-samples.php. this part calculates the crc or xor8:

if ($remeha_crc == 2) { $crcCalc = checksum8xor($hexstrPayload);
} else { $crcCalc = crc16_modbus($hexstrPayload); }

JustinHoeky commented 5 years ago

I only use remeha-samples.php. this part calculates the crc or xor8:

if ($remeha_crc == 2) { $crcCalc = checksum8xor($hexstrPayload); } else { $crcCalc = crc16_modbus($hexstrPayload); }

Hi Juanelc,

I also have that file and i still get a crc error, even though remeha_crc = 2 Not sure what the problem could be, will try to redownload it all.

Would you be able to chat on Discord/Skype? Maybe we could find the error. After that i will create a Merge Request with the working files.

JustinHoeky commented 5 years ago

@juanelc

Let me know if you want to chat further on Discord. Once it's working i will Merge the working files on here. This is what i get in my log when i run it manually:

CRC Error | 2019-09-27 23:08:15 | 02 03| CRC Error | 2019-09-27 23:08:19 | 02 5285c6fbf3 03| CRC Error | 2019-09-27 23:08:23 | 02 03| CRC Error | 2019-09-27 23:08:24 | 02 03| CRC Error | 2019-09-27 23:08:25 | 02 03| CRC Error | 2019-09-27 23:08:27 | 02 03| CRC Error | 2019-09-27 23:08:29 | 02 52c5e7cd 03|

JustinHoeky commented 5 years ago

I only use remeha-samples.php. this part calculates the crc or xor8:

if ($remeha_crc == 2) { $crcCalc = checksum8xor($hexstrPayload); } else { $crcCalc = crc16_modbus($hexstrPayload); }

Hi @juanelc ,

I've set my WiFi closer to the Adafruit and also fixed a better powersupply. Sadly enough i still get the CRC error for some reason.

Can you help me out a bit more? I really want to get it working if possible. My Discord is Justino#6896

Just to be sure, i'm using this one: https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/overview

JustinHoeky commented 4 years ago

Any idea @juanelc ?

juanelc commented 4 years ago

it seem that the data is not properly received: this is the log line: $datatowrite = ' CRC Error | ' . date_format($date, 'Y-m-d H:i:s') . ' | 02 ' . $hexstrPayload . ' ' . $hexstrCRC . ' ' .'03| ' . "\n";

so most of the lines do not contain data. and the hexstrPayload is empty

did you set the baudrate of the esp link correct: for me it was set to 9600 8 n 1

If you comment the CRC check out, you can check if the other data makes sense

there should be additional data traced in the xor8 function here: echo "Got checksum: ", dechex($checksum), "\n";

JustinHoeky commented 4 years ago

it seem that the data is not properly received: this is the log line: $datatowrite = ' CRC Error | ' . date_format($date, 'Y-m-d H:i:s') . ' | 02 ' . $hexstrPayload . ' ' . $hexstrCRC . ' ' .'03| ' . "\n";

so most of the lines do not contain data. and the hexstrPayload is empty

did you set the baudrate of the esp link correct: for me it was set to 9600 8 n 1

If you comment the CRC check out, you can check if the other data makes sense

there should be additional data traced in the xor8 function here: echo "Got checksum: ", dechex($checksum), "\n";

Hi @juanelc , i will give it a try. Will check the Baudrate first. About the CRC check, which line do i have to comment out? Just to be sure. And, you are using this one? https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/overview

rjblake commented 4 years ago

@justinhoeky - start by removing the comments at the start of the remeha.php file to turn debug on - logs should give you more info. It’s line 3 - // error_reporting(E_ALL); - remove the //. Also, run this from command line using php7 remeha.php

JustinHoeky commented 4 years ago

@JustinHoeky - start by removing the comments at the start of the remeha.php file to turn debug on - logs should give you more info. It’s line 3 - // error_reporting(E_ALL); - remove the //. Also, run this from command line using php7 remeha.php

Sorry for the late respone, will give it a try this evening and report back.

JustinHoeky commented 4 years ago

Just to be sure, this is the correct Adafruit right? https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/overview

JustinHoeky commented 4 years ago

@rjblake i've run the following command: sudo -u www-data php7.3 remeha.php

Now i get the following result:

PHP version: 7.3.11-1~deb10u1
Connected to 192.168.0.12:23
Sending request...
Sample Data read:
Data written to log: log/remeha_sample_data.log

************** CRC ERROR!!!! ***********

Baud rate is on 9600 like @juanelc suggested.

Even with error reporting on, i don't get any extra info. Any idea where the extra info/errors are stored?

JustinHoeky commented 4 years ago

@rjblake @juanelc just to let you know, i'm now receiving data! So reinstalling my Pi did the trick even though it was not plannend.

Got some permission issues to fix, and once i got everything working i will create a PR

rjblake commented 4 years ago

This looks like you have some permission issues. Does the user account you are using have required read/write/execute permissions? Suggest creating a folder under the user's home folder with full permissions and executing with simply 'php remeha.php' (or php7 remeha.php, etc.). Also not that the 'log' folder needs to exist below this, or you need to change the location in the remeha.ini file. To test if this is the issue, you can try start with a folder with full permissions and reduce them from there (or run everything as root using sudo command)

On Fri, Nov 1, 2019 at 12:04 AM JustinHoeky notifications@github.com wrote:

@rjblake https://github.com/rjblake i keep getting the following:

PHP version: 7.3.11-1~deb10u1 Connected to 192.168.0.12:23 Sending request... Sample Data read: FFFBFF PHP Warning: file_put_contents(log/remeha_sample_data.log): failed to open stream: Permission denied in /var/www/html/remeha/remeha.php on line 146 Data written to log: log/remeha_sample_data.log

** CRC ERROR!!!! ***

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rjblake/remeha/issues/8?email_source=notifications&email_token=ACLYOOVS7OFNXKNRR6XD36TQRNP77A5CNFSM4GP7EAMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECZQJCA#issuecomment-548603016, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACLYOOSW362NQLIBLSCU56DQRNP77ANCNFSM4GP7EAMA .

JustinHoeky commented 4 years ago

@rjblake i was running it as sudo -u www-data php7.3 remeha-counters.php After removing the "-u www-data" part i don't have these errors anymore.

I do however keep getting the following:

PHP Notice:  Undefined variable: data_counter3 in /var/www/html/remeha/remeha-counters.php on line 92
PHP Notice:  Undefined variable: data_counter4 in /var/www/html/remeha/remeha-counters.php on line 92

and

Last Update:2019-11-01 08:21:58 Time Now:2019-11-01 09:24:31 Elapsed:62.55
PHP Notice:  Undefined variable: controltemperature in /var/www/html/remeha/remeha-samples.php on line 694
PHP Notice:  Undefined variable: solartemperature in /var/www/html/remeha/remeha-samples.php on line 701
PHP Notice:  Undefined variable: pressure in /var/www/html/remeha/remeha-samples.php on line 706
PHP Notice:  Undefined variable: dhwflowrate in /var/www/html/remeha/remeha-samples.php on line 707
PHP Notice:  Undefined variable: heatrequest4 in /var/www/html/remeha/remeha-samples.php on line 809
PHP Notice:  Undefined variable: hruactivebitsbin in /var/www/html/remeha/remeha-samples.php on line 613
PHP Notice:  Undefined variable: solartemperature in /var/www/html/remeha/remeha-samples.php on line 567
PHP Notice:  Undefined variable: solartemperature in /var/www/html/remeha/remeha-samples.php on line 567
PHP Notice:  Undefined variable: controltemperature in /var/www/html/remeha/remeha-samples.php on line 560

Anything i should be worried about, since they are Notices? Or just simply ignore them

Running sudo php7.3 remehe.php still gives me the CRC Error, but will check that one out

rjblake commented 4 years ago

@JustinHoeky - quick question for you. Do you understand PHP code? Happy to help to an extent, but seems some basics need to be understood. @juanelc modified the code for the Remeha Avanta and as such, the codebase is slightly different from that on GitHub. The "remeha.ini" file is the configuration file of sorts that has some specifics and mappings. A quick look shows that a the remeha_counter3 & remeha_counter4 have been set to a null string, as likely not used for the Avanta. This in turn would impact the code in the remeha_counters.php file (i.e. the corresponding code has not been changed). The same applies for the undefined variables in remeha-samples.php. @juanelc has actually added a "Not suppported by Aventa" in the .ini file. As such, you can ignore; but the correct thing would be to amend the code accordingly so that these aren't considered in the first instance. I do not have an Avanta to test changes on, so this would be up to people like @juanelc and yourself and assuming I am happy with the changes, would merge them into the master only if they do not break for the Calenta, etc.

JustinHoeky commented 4 years ago

@rjblake sorry, i just noticed these are indeed the once not supported by Avanta. I do understand PHP, but totally missed it, before i added the IDX data. Sorry for that

I received all the data at the moment, and it's all added to Domoticz (took a while, adding the Devices)

Instead of merging it together, we could also make a folder per model. So remeha/avanta/ and remeha/calenta This way i could optimize the avanta code, without messing with the already working calenta code.

rjblake commented 4 years ago

@JustinHoeky - no problem. Good to hear you've got it working.

Rather than making folder (repo) per model (not a particularly elegant solution), you can create your own repo for this. I did intend to use the 'remeha-identification.php' to detect the boiler type and set parameters accordingly; but have really not had time to do so, hence lack of change to the code (i.e. to really clean it up and make it more efficient, etc.). May revisit it sometime, but not currently.

JustinHoeky commented 4 years ago

@rjblake Hmm, fair enough. I will add a Repo for the avanta. Once i have it up and running it might be an idea to add a link in your Readme.md to the Avanta version, if you are open for that. This way people might find the right version

rjblake commented 4 years ago

@JustinHoeky - sure. Also, if you fork my repo and amend with the code from @juanelc and yourself, it will show as a fork for anyone as well. Closing this issue

rogu22 commented 3 years ago

Hello,

I have dietrich mcx plus, at the beginning connected with D1 mini with Home Assistant compiled with ESPHome as described https://github.com/kakaki/esphome_dietrich but this is for mcr3 (Calenta) and of course i get crc error.

21:02:52][D][sensor:092]: 'Boiler Uptime': Sending state 1078.95801 s with 0 decimals of accuracy [21:02:56][D][sensor:092]: 'Boiler WiFi Signal': Sending state -83.00000 dB with 0 decimals of accuracy [21:02:57][D][custom:243]: counter1 data: 000000000000000000000000100A10401989100000000000F0A7C64B [21:02:57][D][custom:261]: counter2 data: 31303430313938393130303030303030303030304630413743363442 [21:03:12][D][custom:209]: crc error [21:03:12][D][custom:213]: sample data: 28302240E4B3FE3F100A1040A4C3100000000000000000006469FF3F8547204000000000F0A7C64BD34D6230000000000000000000000000F0A7C64B000000000000000000000000100A1040ACC31000

So i found this issue for Remeha Avanta V1 P3. I connected boiler with Recom tool and used sniffer. It is recognised as AvantaPlusV1_P5. Can somebody help me prepare excelsheet so later on i will try update kakaki's yaml. free device connected with AvantaPlusV1_P5

data from sniffer reads : https://pastebin.pl/view/ef425e7f

writes+changed dhw set point https://pastebin.pl/view/b73f938d

thx

omdaomda commented 2 years ago

hello I have dietrich mcx plus, at the beginning connected with D1 mini with Home Assistant
did you solve the problem ?

rogu22 commented 2 years ago

Hi, yes it works with home assistant. Based on kaki's optimization and using sniffer i created xml mapping for mcx plus and later on i updated files from kaki for home assistant.
You will find these files as version dietrich_calentaV1_P5.h https://github.com/kakaki/esphome_dietrich It is ready to use in HA. CRC error is also solved there.