Read Thermostat Mode

Post Reply
juankar
Posts: 498
Joined: Saturday 30 August 2014 20:20
Target OS: Raspberry Pi
Domoticz version:
Location: Spain
Contact:

Read Thermostat Mode

Post by juankar » Tuesday 20 December 2016 20:04

I have a thermostat but there isn't any swith in GUI to change mode I have an utility for that task.
I'm using a virtual switch, events and lua. And it's ok when I change the mode from GUI but when I change the mode from thermostat (manually) the virtual switch does'nt update so I want to use an script.
But I am not able to read the mode from thermo, otherdevice_utility doesn't work for this param. How coul I read the mode of thermostate.

juankar
Posts: 498
Joined: Saturday 30 August 2014 20:20
Target OS: Raspberry Pi
Domoticz version:
Location: Spain
Contact:

Re: Read Thermostat Mode

Post by juankar » Saturday 24 December 2016 14:51

Nobody has the same problem? Just read mode status from thermostat ... it must be dome because Gui shows the actual mode of thermostate so Lua ought be able to read this value.

juankar
Posts: 498
Joined: Saturday 30 August 2014 20:20
Target OS: Raspberry Pi
Domoticz version:
Location: Spain
Contact:

Re: Read Thermostat Mode

Post by juankar » Tuesday 27 December 2016 0:57

Well, I've studied the issue and I've found a patch. I would like if it's good or if it has "secondary effects".
I've changed in SQLHelper.cpp, about line 2952

Code: Select all

uint64_t CSQLHelper::UpdateValue(const int HardwareID, const char* ID, const unsigned char unit, const unsigned char devType, const unsigned char subType, const unsigned char signallevel, const unsigned char batterylevel, const int nValue, std::string &devname, const bool bUseOnOffAction)
{
    return UpdateValue(HardwareID, ID, unit, devType, subType, signallevel, batterylevel, nValue, "", devname, bUseOnOffAction);
}
AS you can see it calls updateValueInt with sValue = ""
I change this code to

Code: Select all

uint64_t CSQLHelper::UpdateValue(const int HardwareID, const char* ID, const unsigned char unit, const unsigned char devType, const unsigned char subType, const unsigned char signallevel, const unsigned char batterylevel, const int nValue, std::string &devname, const bool bUseOnOffAction)
{
   /*OJO Ever set sValue, so we can read sValues for any device in lua */
   char sValue[200];
   sprintf(sValue,"%d", nValue);
    return UpdateValue(HardwareID, ID, unit, devType, subType, signallevel, batterylevel, nValue, sValue , devname, bUseOnOffAction);
}
Now sValue is equal to nValue, so Lus can read sValue of this devices like ThermostateMode or FanMode....
If anybody sees an hidden effect produced by this change, please answer. It nobody answer I create a pull in GitHub

Merry Christmas

juankar
Posts: 498
Joined: Saturday 30 August 2014 20:20
Target OS: Raspberry Pi
Domoticz version:
Location: Spain
Contact:

Re: Read Thermostat Mode

Post by juankar » Friday 30 December 2016 0:48

Well I tried to send this modification to GitHub but Gizmocuz that this is not the way, although he doesn't give any reason.
So I wonder why some devices have to set sValues to "".
Anybody has an answer?

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests