nitaybz / homebridge-cool-automation

Homebridge plugin for Cool Automation - HVAC Systems Controller
GNU General Public License v3.0
3 stars 1 forks source link

Support for Fahrenheit #1

Closed ronluna closed 3 years ago

ronluna commented 3 years ago

Seems like the auto detection between Celsius and Fahrenheit is there but is not being properly triggered, Cool master returns all the values in Fahrenheit with "F" but are ignored by the plugin and all the values are being treated as Celsius and the values shown on homebridge are way higher than the real values .

[1/19/2021, 7:42:50 PM] [CoolAutomation] Sending Command: ls2 [1/19/2021, 7:42:50 PM] [CoolAutomation] Successful response (ls2): [1/19/2021, 7:42:50 PM] [CoolAutomation] [ 'L2.136 ON 069.0F 073.0F Auto Cool OK - 0', 'L2.137 ON 072.0F 069.0F Auto Cool OK - 0', 'L2.138 ON 072.0F 071.0F Auto Cool OK - 0', 'L2.139 ON 072.0F 073.0F Auto Cool OK - 0', 'L2.140 ON 072.0F 071.0F Auto Cool OK - 0'

ronluna commented 3 years ago

I've noticed that the temp unit detection was a little off on coolAutomation/api.js line #65 that the substring was unable to find the F so I've increased it a little. now the plugin can detect the temp units correctly but there is conversion everywhere. which I seems like should not be necessary as once the coolAutomation has been set in F or C the temp unit in the coolAutomation terminal does not get converted.

ronluna commented 3 years ago

The problem seems to be with the temperatures units set on the coolmaster. apparently the plugin was designed only for the coolmaster to be set on celsius but if the coolmasternet is set to Fahrenheit then everything goes crazy on the homebridge plugin

nitaybz commented 3 years ago

sorry... busy days... I'll surely fix it soon

ronluna commented 3 years ago

sounds good. thanks

ronluna commented 3 years ago

to replicate the weird behaviors simply telnet into the coolmasternet and enter:

set deg f

ronluna commented 3 years ago

Tried disabling all the conversations the plugin is currently doing... but seems like homekit requires all temperature to be send in celsius... driving me crazy...

nitaybz commented 3 years ago

I've just uploaded a fix based on the output you presented... Just to get your head straight... HomeKit only talk to the plugins via Celsius, so everything needs to be converted both ways... I've found some differences between the output you presented to the docs Cool Automation provided so I adjusted the state parsing function, hopefully it will solve all the glitches...

Let me know how it goes, and if the problem persist add debug logs to the plugin settings and send the logs again please

ronluna commented 3 years ago

Thanks for the update, Although after applying v0.0.6 The plugin can now correctly detect the Fahrenheit setting in on the controller but they still getting double converted when being displayed on homebridge or the home app

] [2/21/2021, 9:38:06 AM] [CoolAutomation] Sending Command: ls2 [2/21/2021, 9:38:06 AM] [CoolAutomation] Successful response (ls2): [2/21/2021, 9:38:06 AM] [CoolAutomation] [ 'L2.136 ON 074.0F 071.0F Auto Cool OK - 0', 'L2.137 ON 074.0F 071.0F Auto Cool OK - 0', 'L2.138 ON 074.0F 069.0F Auto Cool OK - 0', 'L2.139 ON 074.0F 071.0F Auto Cool OK - 0', 'L2.140 ON 074.0F 069.0F Auto Cool OK - 0' ] [2/21/2021, 9:38:36 AM] [CoolAutomation] Sending Command: ls2 [2/21/2021, 9:38:36 AM] [CoolAutomation] Successful response (ls2): [2/21/2021, 9:38:36 AM] [CoolAutomation] [ 'L2.136 ON 074.0F 071.0F Auto Cool OK - 0', 'L2.137 ON 074.0F 071.0F Auto Cool OK - 0', 'L2.138 ON 074.0F 069.0F Auto Cool OK - 0', 'L2.139 ON 074.0F 071.0F Auto Cool OK - 0', 'L2.140 ON 074.0F 069.0F Auto Cool OK - 0' ]

image image

Seems like min max values also get double converted as seen on the screenshot

ronluna commented 3 years ago

Reviewed one more time the substrings on api.js 0.6 to find out if the unit is on C or F and at least on my controller they were off by 1 or 2 characters. After modifying the substring calculation things finally started to work. The additional changes added on 0.6 were still required in order to get F units working correctly.

I'm still testing everything out... I'll report back if I find something weird.

Here is my substring character mapping:

                // verify temp unit
                let celsius = true
                if (d.substring(11, 17).includes('F'))
                        celsius = false

                return {
                        uid: d.substring(0, 6).trim(),
                        onoff: d.substring(7, 10).trim(),
                        st: parseFloat(celsius ? d.substring(11, 15).trim() : d.substring(11, 16).trim()),
                        rt: parseFloat(celsius ? d.substring(17, 21).trim() : d.substring(18, 23).trim()),
                        fspeed: celsius ? d.substring(23, 27).trim().toUpperCase() : d.substring(25, 29).trim().toUpperCase(),
                        mode: celsius ? d.substring(28, 32).trim().toUpperCase() : d.substring(30, 34).trim().toUpperCase(),
                        flr: celsius ? d.substring(33, 36).trim() : d.substring(35, 38).trim(),
                        filt: celsius ? d[38] : d[38],
                        dmnd: celsius ? d[40] : d[40],
                        tunit: celsius ? 'C' : 'F'
                }
        })
nitaybz commented 3 years ago

@ronluna Please check the latest version

oogje commented 3 years ago

Thank you @ronluna, @nitaybz. I've been running 0.7 since a few minutes after it was posted. Looking great.