homebridge-tuya icon indicating copy to clipboard operation
homebridge-tuya copied to clipboard

iolloi wifi thermostat electric floorheating

Open paqpaqpaq opened this issue 3 years ago • 83 comments

I got this thermostat working

{ "type": "SimpleHeater", "name": "Verwarming Slaapkamer", "id": "xxx", "key": "xxx", "manufacturer": "iolloi", "model": "WiFi Thermostat", "noCool": false, "noSwing": true, "maxTemperature": 25, "dpActive": 1, "dpDesiredTemperature": 2, "dpCurrentTemperature": 3, "noChildLock": true }

Now, my "issue' is in the dpActive. This thermostat has no json (so it seems in the developers cloud) for idle state. In other words, the Thermostat is OFF, meaning grey tile, and the display on the device itself is OFF too. the Thermostat is ON, meaning red tile / heating, regardless its set temperature. At first it is green, but at reloading the home app it turns red. So dpActive is either true or false

Now, the cloud log shows that dpActive is most likely POWER. However, the logs also shows whether the thermostat's LOAD is on or off.

In other words, would there be a way for the tile to be green in the first place, and based on its load turning red or green? Like one would expect from a thermostat?

paqpaqpaq avatar Oct 13 '21 15:10 paqpaqpaq

Any luck / news on this one?

paqpaqpaq avatar Dec 28 '21 21:12 paqpaqpaq

I was facing a similar issue, so I created a fork where I added this functionality. The added SimpleThermostatAccessory will allow you to split the heating/idle condition, from the program/schedule state. I am by no means a good programmer, so please use with caution ;). If it seems to be working for more people, I will send in a pull requests to add it to iRayanKhan official Homebridge plugin

andMaximus avatar Feb 09 '22 10:02 andMaximus

I was facing a similar issue, so I created a fork where I added this functionality. The added SimpleThermostatAccessory will allow you to split the heating/idle condition, from the program/schedule state. I am by no means a good programmer, so please use with caution ;). If it seems to be working for more people, I will send in a pull requests to add it to iRayanKhan official Homebridge plugin

ooo great!

I will try this later today

paqpaqpaq avatar Feb 09 '22 10:02 paqpaqpaq

@andMaximus I did some testing. First, if I change via config-ui-x, there is an extra platform configured "tuya", as where my thermostats run on "tuyalan" So I just changed the config for that instead.

Now, my config (of 1 specific thermostat) looks like so: `{

                "type": "SimpleThermostat",
                "name": "Verwarming Slaapkamer",
                "id": "ID",
                "key": "KEY",
                "manufacturer": "iolloi",
                "model": "WiFi Thermostat",
                "noCool": false,
                "noSwing": true,
                "maxTemperature": 25,
                "dpActive": 118,
                "dpProgramState": 103,
                "dpDesiredTemperature": 2,
                "dpCurrentTemperature": 3,
                "noChildLock": true
            }
            `

The thermostat responds, 'loads' power, but remains green (no load) if I do it like so, there are errors in the log (exceeding threshold)

`    {
                    "type": "SimpleThermostat",
                    "name": "Verwarming Slaapkamer",
                    "id": "ID",
                    "key": "KEY",
                    "manufacturer": "iolloi",
                    "model": "WiFi Thermostat",
                    "noCool": false,
                    "noSwing": true,
                    "maxTemperature": 25,
                    "dpActive": 118,
                    "dpProgramState": 103,
                    "dpDesiredTemperature": 102,
                    "dpCurrentTemperature": 106,
                    "noChildLock": true
                }`

if I leave out dprogramstate, [Tuya] Heard back from Verwarming Slaapkamer with command 10 [10/02/2022, 13:58:55] [TuyaLan] Ready to handle Verwarming Slaapkamer (SimpleThermostat:3.3) with signature {"1":true,"2":22,"3":17,"4":"0","6":false,"12":0,"101":19,"102":"2","103":0,"104":2,"105":true,"107":false,"108":false,"110":5}

[Tuya] Heard back from Verwarming Slaapkamer with command 8 [Tuya] Thermostat changed: {"1":true,"2":22,"3":18,"4":"0","6":false,"12":0,"101":19,"102":"2","103":0,"104":2,"105":true,"107":false,"108":false,"110":5} [Tuya] Heard back from Verwarming Slaapkamer with command 8 [Tuya] Thermostat changed: {"1":true,"2":22,"3":18,"4":"0","6":false,"12":0,"101":20,"102":"2","103":0,"104":2,"105":true,"107":false,"108":false,"110":5}

remains green too

So, I guess i need to figure out the actual dP's form my thermostat?

paqpaqpaq avatar Feb 10 '22 13:02 paqpaqpaq

ugh... I specified further dp settings, and now none of my tuyalan devices are recognized. OK I will start over with my image back-up (fortunately)

paqpaqpaq avatar Feb 10 '22 13:02 paqpaqpaq

Hi @paqpaqpaq, you have to indeed figure out the meaning of each DP your thermostat sends out. Doesn’t seem like these are standardized across the different brands. I uncovered the meaning of the DPs by trail and error: look at the status messages that the thermostat puts out, input a change via the Tuya app, and then see what has changed. That way I noticed that f.e. DP 118 changed from “warming” to “heating”, meaning that the thermostat turned on the heating element.

Based on your copied data from the log, these points correspond to the DPs:

[Tuya] Thermostat changed: {"1":true,"2":22,"3":18,"4":"0","6":false,"12":0,"101":19,"102":"2","103":0,"104":2,"105":true,"107":false,"108":false,"110":5}

My guess would be that DP 2 corresponds to the setpoint temperature which is currently 22 degrees. Please check this though by changing it in the Tuya app. It might also be the current temperature.

I would also recommend that you completely remove the device before changing the type, you have defined the noCool and noSwing parameters, which the simple thermostat doesn’t use.

You also haven’t defined what text values within a DP correspond to heating being on or off, as well as the currently active program. Take my example of DP 118 again, this contains “heating” when the heating is on, and “warming” when heating is off.

Good luck 😉

andMaximus avatar Feb 11 '22 09:02 andMaximus

@andMaximus OK thanks. Could you please share how your config looks like for a thermostat?

paqpaqpaq avatar Feb 11 '22 09:02 paqpaqpaq

@paqpaqpaq this is what mine looks like right now:

    {
        "devices": [
            {
                "type": "SimpleThermostat",
                "name": "Vloerverwarming",
                "id": "blablabla",
                "key": "blablablabla",
                "manufacturer": "MRC",
                "model": "MRC Remote",
                "minTemperature": 5,
                "maxTemperature": 30,
                "dpActive": 118,
                "dpProgramState": 103,
                "heatingIndicatorOff": "warming",
                "heatingIndicatorOn": "heating",
                "scheduledHeatingOff": "FROST",
                "scheduledHeatingOn": "AUTO",
                "dpDesiredTemperature": 102,
                "dpCurrentTemperature": 106,
                "temperatureDivisor": 10,
                "thresholdTemperatureDivisor": 10,
                "targetTemperatureDivisor": 10
            }
        ],
        "platform": "TuyaLan"
    }

andMaximus avatar Feb 11 '22 09:02 andMaximus

@andMaximus thanks again. Man, I forgot where I determined or found those dp values

I only need to figure out programstate, correct? Can you check your log maybe to see what position that is? That way we could A-B to find out exactly what position is what.

I'm guessing I'll be needing 105. That is switching between true or false when I resp. heat or not.

paqpaqpaq avatar Feb 11 '22 10:02 paqpaqpaq

if I switch OFF: 103 FROST If i switch back ON: 103 AUTO

105 still the only value that is flipping true/false. But this doesn't reflect on the color of the tile. It remains green. when 103 = auto

I'm pretty sure this is correct though:

{ "type": "SimpleThermostat", "name": "Verwarming Slaapkamer test", "id": "ID", "key": "TOKEN", "manufacturer": "iolloi", "model": "WiFi Thermostat", "maxTemperature": 25, "dpActive": 105, "dpProgramState": 103, "heatingIndicatorOff": "warming", "heatingIndicatorOn": "heating", "scheduledHeatingOff": "FROST", "scheduledHeatingOn": "AUTO", "dpDesiredTemperature": 2, "dpCurrentTemperature": 3 },

paqpaqpaq avatar Feb 11 '22 10:02 paqpaqpaq

@paqpaqpaq Can you post two log items, 1) for when the heating is "off" and 2) for when the heating is on? Similarly, does it have a programmed state (running on schedule) vs. manual state (running only when manually requested)?. If so, also share those separately.

This is what my log looks like, probably won't help much as the DPs are different for each brand and device. [Tuya] Thermostat changed: {"101":"time_only","102":180,"103":"AUTO","104":0,"106":215,"107":false,"108":false,"109":0,"110":"1","111":"1","112":0,"114":"0_5","115":10,"117":60,"118":"warming","123":4,"124":"other","125":"12k","126":true,"127":true}

I remember using this guide to figure out the DP as well, would be great if someone added it to the wiki of this plugin

andMaximus avatar Feb 11 '22 10:02 andMaximus

@paqpaqpaq Can you post two log items, 1) for when the heating is "off" and 2) for when the heating is on? Similarly, does it have a programmed state (running on schedule) vs. manual state (running only when manually requested?

This is what my log looks like, probably won't help much as the DPs are different for each brand and device. [Tuya] Thermostat changed: {"101":"time_only","102":180,"103":"AUTO","104":0,"106":215,"107":false,"108":false,"109":0,"110":"1","111":"1","112":0,"114":"0_5","115":10,"117":60,"118":"warming","123":4,"124":"other","125":"12k","126":true,"127":true}

I remember using this guide to figure out the DP as well, would be great if someone added it to the wiki of this plugin

This is my output, going from heating to idle. (tile is green in either state)

[Tuya] Sending Verwarming Slaapkamer test 2 {"2":18} [Tuya] Heard back from Verwarming Slaapkamer test 2 with command 8 [Tuya] Thermostat changed: {"1":true,"2":18,"3":18,"4":"0","6":false,"12":0,"101":20,"102":"2","103":0,"104":2,"105":true,"107":false,"108":false,"110":5} [Tuya] Heard back from Verwarming Slaapkamer test 2 with command 8 [Tuya] Thermostat changed: {"1":true,"2":18,"3":18,"4":"0","6":false,"12":0,"101":20,"102":"2","103":0,"104":2,"105":false,"107":false,"108":false,"110":5}

so, dp105 goes from true to false, indicating this is the one I am after.

dp101 is almost certain the external sensor.

paqpaqpaq avatar Feb 11 '22 10:02 paqpaqpaq

So the thermostat doesn't have a schedule? That's what the other input (dpProgramState) looks at.

To get the active working (orange / green tile), I think this should be your settings:

"dpActive": 105, "heatingIndicatorOff": false, "heatingIndicatorOn": true,

andMaximus avatar Feb 11 '22 11:02 andMaximus

So the thermostat doesn't have a schedule? That's what the other input (dpProgramState) looks at.

To get the active working (orange / green tile), I think this should be your settings:

"dpActive": 105, "heatingIndicatorOff": false, "heatingIndicatorOn": true,

I will try that. Going through the list logs on the tuya developers cloud, I am positive now it needs to be 105.

sounds logical, but sorry, no... tile remains green.

paqpaqpaq avatar Feb 11 '22 11:02 paqpaqpaq

Might be due to a data type mismatch, as DP 105 is a bool (true/false), whereas the comparison is looking for a string.

Could you go the following file ./lib/SimpleThermostatAccessory.js and change line 129 into: return dps[this.dpActive] ? Characteristic.CurrentHeaterCoolerState.HEATING : Characteristic.CurrentHeaterCoolerState.IDLE;

andMaximus avatar Feb 11 '22 11:02 andMaximus

awesome!

Status change takes reopening the home app though.

maybe @iRayanKhan could be of any further assistance here by updating his plugin?

paqpaqpaq avatar Feb 11 '22 11:02 paqpaqpaq

I'm having the same issues in the delay between setting something and the status updating. I think I need to make some changes in the this.device.on('change' code starting at line 73.

andMaximus avatar Feb 11 '22 15:02 andMaximus

@paqpaqpaq Did some digging and I found out why it didn't automatically update. Pushed a new version here which fixes automatic instantaneous updating.

Same applies as before, overwrite the ./index.js, ./lib/SimpleThermostatAccessory and ./config.schema.json files in node_modules.

I unfortunately can't test the dpActive true/false behavior, as my device does not work that way, so for now overwrite line 137 of ./lib/SimpleThermostatAccessory.js with the following:

return dps[this.dpActive] ? Characteristic.CurrentHeaterCoolerState.HEATING : Characteristic.CurrentHeaterCoolerState.IDLE;

andMaximus avatar Feb 12 '22 12:02 andMaximus

Thanks. It only seems to be working when changing from heating to idle, not from idle to heating (so true to false, not false to true)

paqpaqpaq avatar Feb 12 '22 12:02 paqpaqpaq

Try replacing return dps[this.dpActive] with just dps on line 137, thats how I have it for string comparison

return dps ? Characteristic.CurrentHeaterCoolerState.HEATING : Characteristic.CurrentHeaterCoolerState.IDLE;

andMaximus avatar Feb 12 '22 13:02 andMaximus

nope, now they're all back to heating

paqpaqpaq avatar Feb 12 '22 14:02 paqpaqpaq

You could add a console.log line to check the data that is actually passed there. Put console.log(dps); in between 136 and 137 and reload homebridge. If it indeed shows true / false in the homebridge log then there is something else amiss code wise. If it shows something like this {"105":true}, you need to add something to "unpack" the value from it, like dps[this.dpActive] was used previously.

andMaximus avatar Feb 12 '22 15:02 andMaximus

@andMaximus I will try this now. Also: switching OFF the thermostat does not go for the intend (switchting it off to grey) Home shows grey but isn;t off, and is back to green (or orange) on reload.

paqpaqpaq avatar Feb 13 '22 11:02 paqpaqpaq

OK as for the extra loggin: [Tuya] Heard back from Verwarming Slaapkamer with command 8 false [Tuya] Heard back from Verwarming Slaapkamer with command 8 true

I also seem to have an issue with increments of 0,5. They need to be 1,0

paqpaqpaq avatar Feb 13 '22 11:02 paqpaqpaq

@paqpaqpaq

Also: switching OFF the thermostat does not go for the intend (switching it off to grey) Home shows grey but isn't off, and is back to green (or orange) on reload.

This is intended behavior; the on/off switch changes the program-state of the thermostat by going from the automatic schedule to in my case frost mode, where the schedule is turned off. Don't you use your thermostats built in schedule for heating? The orange / green indicator shows whether the heating element is active, which in your case would probably be DP 105.

I still don't understand why _getCurrentHeaterCoolerState (orange / green indicator) doesn't work for you, given the manual override we put in. Let's log some more, could you add some extra console.logs between line 88 and 89?

console.log('The new CurrentHeaterCoolerState is:');
console.log(newCurrentHeaterCoolerState);
console.log('The existing CurrentHeaterCoolerState is');
console.log(characteristicCurrentHeaterCoolerState.value);

andMaximus avatar Feb 13 '22 12:02 andMaximus

No, I don't use any of the built in schedules or geo settings. All is handled within homekit. (Automated based on actions, not time)

I will implement the extra logging. Although I do need to find a away for the 1 degree increments; it gives random responses when it lands on x,5. Then logging is not much use.

paqpaqpaq avatar Feb 13 '22 12:02 paqpaqpaq

@paqpaqpaq you can set the increments on line 65, change the 0.5 to 1. minStep: this.device.context.minTemperatureSteps || 0.5 Thanks for mentioning, updated the thermostat-feature to also take it as an input.

andMaximus avatar Feb 13 '22 12:02 andMaximus

§ You sure it needs to be there?

The new CurrentHeaterCoolerState is: [13/02/2022, 13:35:34] ReferenceError: Cannot access 'newCurrentHeaterCoolerState' before initialization at TuyaAccessory. (/usr/local/lib/node_modules/homebridge-tuya/lib/SimpleThermostatAccessory.js:89:13) at TuyaAccessory.emit (events.js:400:28) at TuyaAccessory._change (/usr/local/lib/node_modules/homebridge-tuya/lib/TuyaAccessory.js:407:18) at TuyaAccessory._msgHandler_3_3 (/usr/local/lib/node_modules/homebridge-tuya/lib/TuyaAccessory.js:333:30) at /usr/local/lib/node_modules/homebridge-tuya/node_modules/async/dist/async.js:3983:13 at Object.process (/usr/local/lib/node_modules/homebridge-tuya/node_modules/async/dist/async.js:1648:21) at /usr/local/lib/node_modules/homebridge-tuya/node_modules/async/dist/async.js:1506:23 at /usr/local/lib/node_modules/homebridge-tuya/node_modules/async/dist/async.js:74:45 at internal/process/task_queues.js:141:7 at AsyncResource.runInAsyncScope (async_hooks.js:197:9) at AsyncResource.runMicrotask (internal/process/task_queues.js:138:8) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:95:5) [13/02/2022, 13:35:34] Got SIGTERM, shutting down Homebridge...

paqpaqpaq avatar Feb 13 '22 12:02 paqpaqpaq

Did you put it before or after? It needs to go after const newCurrentHeaterCoolerState = this._getCurrentHeaterCoolerState(changes[this.dpActive]);

andMaximus avatar Feb 13 '22 12:02 andMaximus

my bad... sorry

[Tuya] Sending Verwarming Slaapkamer {"2":20} [Tuya] Heard back from Verwarming Slaapkamer with command 8 [Tuya] Thermostat changed: {"1":true,"2":20,"3":18,"4":"0","6":false,"12":0,"101":19,"102":"2","103":0,"104":2,"105":false,"107":false,"108":false,"110":5} [Tuya] Heard back from Verwarming Slaapkamer with command 8 The new CurrentHeaterCoolerState is: 1 The existing CurrentHeaterCoolerState is 1 [Tuya] Thermostat changed: {"1":true,"2":20,"3":18,"4":"0","6":false,"12":0,"101":19,"102":"2","103":0,"104":2,"105":true,"107":false,"108":false,"110":5}

If I'd reload the home first (tile going orange), the existing state is 2

paqpaqpaq avatar Feb 13 '22 12:02 paqpaqpaq