notenoughtech / NodeRED-Projects

This is where you can find the code related to projects published on notenoughtech.com
19 stars 12 forks source link

TRV Auto Calibration - Error Calculate offset #3

Open Daniel-WW opened 1 year ago

Daniel-WW commented 1 year ago

Hi Mat, thanks a lot for your great work and all the very useful videos on YouTube! With your information, I could already solve a lot of problems in my smart-home-setup. ;-)

Now, I tried to use the "TRV Auto Calibration" flow in node-red. I customized the script for my sensors. I use Moes/Tuya TV02 TVR and Tuya Temperature Sensors.

But till now, for the node "Calculate offset" I always got an Error-Message: function : (error) TypeError: Cannot read property 'temp' of undefined

To solve the problem, I double-checked the code and the sensors, but I couldn't fix it. Do you - or someone else - have any idea, what could be the problem?

If I should post more information (code), let me know.

I'm a very newbie in working with node-red, and I would be grateful about every kind of help. - Maybe I did an easy beginner-fault. ;-)

Best regards - Daniel

notenoughtech commented 1 year ago

I'm away from the computer but the way I see it your temperature isn't reported. So the "temp" variable isnt set when calculating the offset. Check if your temperature is submitted in the same as mine format.

On Fri, 23 Dec 2022, 14:37 Daniel-WW, @.***> wrote:

Hi Mat, thanks a lot for your great work and all the very useful videos on YouTube! With your information, I could already solve a lot of problems in my smart-home-setup. ;-)

Now, I tried to use the "TRV Auto Calibration" flow in node-red. I customized the script for my sensors. I use Moes/Tuya TV02 https://www.zigbee2mqtt.io/devices/TV02-Zigbee.html TVR and Tuya Temperature Sensors

— Reply to this email directly, view it on GitHub https://github.com/notenoughtech/NodeRED-Projects/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDRL23LTWIJLH25T2L3TLTWOW2I3ANCNFSM6AAAAAATHZP7AA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Daniel-WW commented 1 year ago

Hi, thanks for your fast response. I did set a debug-node to see the output of the temperature-sensor. This is what I receive, from the sensor:

zigbee2mqtt/temp_wohnzimmer : msg.payload : string[84] "{"battery":81,"humidity":55.52,"linkquality":255,"temperature":19.76,"voltage":2900}"

So I receive a temperature value, but I don't know if it is the right format. Do I have to convert the content, with a json-node?

Thanks for help.

notenoughtech commented 1 year ago

Hi,

I had a look at the flow again, and the reason why this happens is that your temperature sensor sent the update before TRV. If you run your TRV first (change the setpoint, to trigger the update), it will set everything and then you can receive the payload from the sensor. I'll try to arrange some time and fix this bug at some point, it only happens on the first instance. Mat Zolnierczyk

Maker, Robotics Engineer

Owner | NotEnoughTech @.*** notenoughtech.com Teesside, North Yorkshire, UK [image: facebook] https://www.facebook.com/NotEnoughTECH/ [image: twitter] https://twitter.com/NotEnoughTECH [image: linkedin] https://www.linkedin.com/in/mat-zolnierczyk/ [image: instagram] https://www.instagram.com/notenoughtech/

On Fri, Dec 23, 2022 at 4:52 PM Daniel-WW @.***> wrote:

Hi, thanks for your fast response. I did set a debug-node to see the output of the temperature-sensor. This is what I receive, from the sensor:

zigbee2mqtt/temp_wohnzimmer : msg.payload : string[84] "{"battery":81,"humidity":55.52,"linkquality":255,"temperature":19.76,"voltage":2900}"

So I receive a temperature value, but I don't know if it is the right format. Do I have to convert the content, with a json-node?

Thanks for help.

— Reply to this email directly, view it on GitHub https://github.com/notenoughtech/NodeRED-Projects/issues/3#issuecomment-1364112235, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDRL27ZK2RXUVGQDTVWFKLWOXKGDANCNFSM6AAAAAATHZP7AA . You are receiving this because you commented.Message ID: @.***>

Daniel-WW commented 1 year ago

Hi Mat,

thanks for your help and advices. Unfortunately, the problem couldn't be solved only by running (triggering) the TRV. (I always received the same error message.) What I had to do, was exclude the "Suppress updates" switch node and then trigger the TRV for the first time. - After the first run, I could include the "Suppress updates" switch node again, and from then on the flow works fine.

But there is a catch, namely that I have to repeat this procedure whenever Node-Red fails or if my server has to be restarted. - Perhaps a permanent working solution can be found in the future. ;-)

Thanks again for your great work and best regards - Daniel

Git-Vi commented 1 year ago

Hi Mat, thank you for your great job, the solution is really useful. I should say I also see a lot of errors in my log. I hope if you have time you can adjust the solution and fix it. Thank you again!

01/27/2023 2:19:52 PM 27 Jan 14:19:52 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 2:19:52 PM 27 Jan 14:19:52 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 2:49:51 PM 27 Jan 14:49:51 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 2:49:52 PM 27 Jan 14:49:52 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 2:49:52 PM 27 Jan 14:49:52 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 3:19:51 PM 27 Jan 15:19:51 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 3:19:51 PM 27 Jan 15:19:51 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp')

notenoughtech commented 1 year ago

Do you have a persistent context enabled in Nodered? These values should be stored in flow context. The only reason for these not being set is either reeboot of the machine or full deployment of another flow

On Sun, 29 Jan 2023, 12:39 Git-Vi, @.***> wrote:

Hi Mat, thank you for your great job, the solution is really useful. I should say I also see a lot of errors in my log. I hope if you have time you can adjust the solution and fix it. Thank you again!

01/27/2023 2:19:52 PM 27 Jan 14:19:52 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 2:19:52 PM 27 Jan 14:19:52 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 2:49:51 PM 27 Jan 14:49:51 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 2:49:52 PM 27 Jan 14:49:52 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 2:49:52 PM 27 Jan 14:49:52 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 3:19:51 PM 27 Jan 15:19:51 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp') 01/27/2023 3:19:51 PM 27 Jan 15:19:51 - [error] [function:Calculate offset] TypeError: Cannot read properties of undefined (reading 'temp')

— Reply to this email directly, view it on GitHub https://github.com/notenoughtech/NodeRED-Projects/issues/3#issuecomment-1407652758, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDRL24SMPMC5CPKVKRACLLWUZQGXANCNFSM6AAAAAATHZP7AA . You are receiving this because you commented.Message ID: @.***>

Git-Vi commented 1 year ago

Hi Mat, after your comment I have found the post about Contest and uncommented the follow part of the setting.js file I need time to check if it works for me.
https://nodered.org/docs/user-guide/context contextStorage: { default: { module: "localfilesystem" } }

I see in my log next now: 1/29/2023, 2:19:10 PMnode: Calculate offset function : (error) "TypeError: Cannot read properties of undefined (reading 'temp')" 1/29/2023, 2:19:11 PMnode: bedroom_temperature zigbee2mqtt/bedroom_temperature : msg.payload : Object { battery: 82, device: object, humidity: 48.2, linkquality: 105, temperature: 21.53 … } 1/29/2023, 2:20:50 PMnode: bedroom_trv zigbee2mqtt/bedroom_trv : msg.payload : Object { auto_lock: "AUTO", away_mode: "OFF", away_preset_days: 92, away_preset_temperature: 16, battery_low: false … } 1/29/2023, 2:20:50 PMnode: bedroom_trv zigbee2mqtt/bedroom_trv : msg.payload : Object { auto_lock: "AUTO", away_mode: "OFF", away_preset_days: 92, away_preset_temperature: 16, battery_low: false … }

zigbee2mqtt/bedroom_trv : msg.payload : Object object auto_lock: "AUTO" away_mode: "OFF" away_preset_days: 92 away_preset_temperature: 16 battery_low: false boost_time: 300 child_lock: "LOCK" comfort_temperature: 19 current_heating_setpoint: 19 device: object eco_temperature: 15 force: "normal" holidays: array[6] holidays_schedule: "06:00/19°C 08:00/15°C 11:30/15°C 12:30/15°C 17:30/19°C 22:00/15°C" linkquality: 109 local_temperature: 20.5 local_temperature_calibration: -1 max_temperature: 23 min_temperature: 15 position: 45 preset: "manual" running_state: "heat" system_mode: "auto" update: object update_available: false valve_detection: null week: "5+2" window_detection: "OFF" window_detection_params: object window_open: false workdays: array[6] workdays_schedule: "06:00/19°C 08:00/15°C 11:30/15°C 12:30/15°C 17:30/19°C 22:00/15°C"

zigbee2mqtt/bedroom_temperature : msg.payload : Object object battery: 82 device: object humidity: 48.2 linkquality: 105 temperature: 21.53 voltage: 2900

Git-Vi commented 6 months ago

Hello @Daniel-WW I am wondering if you had a chance to solve the issue :) Thank you in advance

Daniel-WW commented 6 months ago

@Git-Vi Hi, since my last comment I did a lot of changes in my system, so that I can't answer exactly how I solved the problem, described above. What I could say is, that in some cases - especially in the first run, after restart - variables has the value "undefined", which means, that they didn't get a right value till then.

To rule this out, a change node should be set that gives the variable a specific value (eg. True) if it is recognized as undefined. Then the next time the flow retrieves the variable, it will have a usable value and the flow can run.

I hope this advice can help you to find a solution for your problem.

Git-Vi commented 6 months ago

@Daniel-WW thank you for your reply. Btw, yesterday I finished with my flow that is based on your one but it has a lot of changes, if you are interested I can share it