I'm using modbus-read (v1.2.0) , to retrieve the power generated by a SMA sunny boy 1.5 inverter with success. However when the power generated is zero (at night for instance), I start having negative values.
Domoticz version: 4.10717
Python version: 3.5.3
HW Configuration:
Screenshot in the end of a production day: (4w)
Example when the sensor should be zero:
Do you have any idea ... something I can adjust? Have you ever been through something similar?
If you need more information, please let me know.
Thanks
Python plugin: modbus TCP - return negative values when the solar system return 0
Moderator: leecollings
-
- Posts: 14
- Joined: Tuesday 23 June 2020 22:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: modbus TCP - return negative values when the solar system return 0
Hello, I have got the same problem as yours.
The negative value you have is due to the fact than your solar system produce « 0 » and instead of sending « 0 » to Domoticz, it send an hexa value « 0x8000 0000 »; it corresponds in signed decimal to « -2147483648 ». This code corresponds to the NaN (not a number) value of your solar system; you should probably find it in the documentation of your solar system.
Here what I have done to get « 0 » instead of this negative value. As Domoticz doesn’t look like being able to deal with NaN value as it cannot be set as a parameter in the Domoticz configuration, nor in the plugin mod is I use, I have created a TRIGGER at DB level to change the negative value to « 0 ».
I have run the following command in ssh session on my Raspberry:
(You have to replace « 44 » with the idx of your concerned device » and adapt path to your Domoticz DB).
If you have trouble after adding the trigger (ie: values are not anymore update for some or all devices) you can remove it with the following command:
Here how to add the trigger:
The negative value you have is due to the fact than your solar system produce « 0 » and instead of sending « 0 » to Domoticz, it send an hexa value « 0x8000 0000 »; it corresponds in signed decimal to « -2147483648 ». This code corresponds to the NaN (not a number) value of your solar system; you should probably find it in the documentation of your solar system.
Here what I have done to get « 0 » instead of this negative value. As Domoticz doesn’t look like being able to deal with NaN value as it cannot be set as a parameter in the Domoticz configuration, nor in the plugin mod is I use, I have created a TRIGGER at DB level to change the negative value to « 0 ».
I have run the following command in ssh session on my Raspberry:
(You have to replace « 44 » with the idx of your concerned device » and adapt path to your Domoticz DB).
If you have trouble after adding the trigger (ie: values are not anymore update for some or all devices) you can remove it with the following command:
Code: Select all
# sqlite3 /home/pi/domoticz/domoticz.db
drop trigger SetNaNToZeroForIdx44;
Code: Select all
# sqlite3 /home/pi/domoticz/domoticz.db
CREATE TRIGGER SetNaNToZeroForIdx44 after UPDATE
ON DeviceStatus
WHEN NEW.ID=44
AND CAST(NEW.sValue AS INT) < 0
BEGIN
UPDATE DeviceStatus SET sValue=0 WHERE ID=44;END;
Who is online
Users browsing this forum: No registered users and 1 guest