kiwi-cam / homebridge-broadlink-rm

[This fork supports TV accessories] Broadlink RM Mini and Pro plugin for homebridge: https://github.com/nfarina/homebridge
Apache License 2.0
304 stars 96 forks source link

Pickup the temperature sensor and humidity sensor in the cable #7

Closed kiwi-cam closed 4 years ago

kiwi-cam commented 4 years ago

Any idea how to pickup the temperature sensor and humidity sensor in the cable that it ships with?

I am unable to see where I have access to 4.2.6 version to download it. HomeBridge web UI only shows 4.2.5 and I can't see it on GitHub unless I'm on the Teams or something.

Originally posted by @ninm002 in https://github.com/kiwi-cam/homebridge-broadlink-rm/issues/3#issuecomment-642649255

kiwi-cam commented 4 years ago

@ninm002 It's a long shot but I found some code in another fork that claims to pull temperature data from RM4 devices. It might work for us. I haven't received my RM4 yet to test myself but if you're keen you can install the beta version and give it a go.

npm install -g homebridge-broadlink-rm-pro@beta

ninm002 commented 4 years ago

How do I call the data from the device? I didn't see an example in the config.json I now have the beta installed.

kiwi-cam commented 4 years ago

No issues so far then?

Getting the temperature from the device is the default behaviour for the Aircon accessory type. If you don't specify mqttURL, temperatureFilePath, or w1DeviceID in your config.json it will use the Broadlink device.

ninm002 commented 4 years ago

Sorry. That is going over my head. I installed the beta software, and previous features still work. I do not see how to view the temperature or humidity. Do you mean the AirConditioner accessory in the config.json example?

This is what I have... "platform": "homebridge-broadlink-rm-pro.BroadlinkRM", "name": "homebridge-broadlink-rm-pro.BroadlinkRM", "host": "10.0.1.55", "mac": "24:DF:A7:XX:XX:XX", "hideScanFrequencyButton": true, "hideLearnButton": false, "hideWelcomeButton": true, "monitored_conditions": [ "temperature", "humidity"

CVHvisuals commented 4 years ago

No issues so far then?

Getting the temperature from the device is the default behaviour for the Aircon accessory type. If you don't specify mqttURL, temperatureFilePath, or w1DeviceID in your config.json it will use the Broadlink device.

[Broadlink RM] [INFO] Discovered Broadlink RM 4 Pro (61a2) Connects fine with beta4, IR works, but RF won't. Log says scanning but never finds frequency.

Ive been attempting to get the inline sensor working that is in the usb cable, but no luck yet.

CVHvisuals commented 4 years ago

I should mention that when I manually entered the host info, it showed up as the wrong device and I was unable to log a code on RF and IR.

Faisalthe01 commented 4 years ago

Hi @ninm002, just wanted to check if the temperature sensor worked with the new beta update from kiwi-cam? I want to order Mini 4 so just wanted to make sure.

ninm002 commented 4 years ago

I have not been able to utilize the sensor built into the cable, yet. But the RM4 does work great! I would recommend it over the larger RM3.

-Zachary

On Jul 21, 2020, at 6:50 AM, Faisal notifications@github.com wrote:

 Hi @ninm002, just wanted to check if the temperature sensor worked with the new beta update from kiwi-cam? I want to order Mini 4 so just wanted to make sure.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Faisalthe01 commented 4 years ago

I have not been able to utilize the sensor built into the cable, yet. But the RM4 does work great! I would recommend it over the larger RM3.

@ninm002, KiwiCam made some changes to his Broadlink RM JS (Rm Testing) on July 15 that added code to read temperature off RM4. So it did not work then? I have RM Mini 3, it works fine too just wanted to get temperature as well so was thinking about RM3 Mini

ninm002 commented 4 years ago

The code was updated. Yes. I am running the newest code with the feature that is added. I however do not have the syntax to use in the homebridge Config.json file. I don’t know how to make it work. Maybe it’s an easy operation, I just don’t know how.

-Zachary

On Jul 21, 2020, at 7:51 AM, Faisal notifications@github.com wrote:

 I have not been able to utilize the sensor built into the cable, yet. But the RM4 does work great! I would recommend it over the larger RM3. …

@ninm002, KiwiCam made some changes to his Broadlink RM JS (Rm Testing) on July 15 that added code to read temperature off RM4. So it did not work then? I have RM Mini 3, it works fine too just wanted to get temperature as well so was thinking about RM3 Mini

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Faisalthe01 commented 4 years ago

The code was updated. Yes. I am running the newest code with the feature that is added. I however do not have the syntax to use in the homebridge Config.json file. I don’t know how to make it work. Maybe it’s an easy operation, I just don’t know how.

I see. You need to remove any config related to Temperature from your config file like temperatureFromFile or mqtt temperature only then AirCon accessory picks up the current temperature from the device. See how you go.

kiwi-cam commented 4 years ago

I'd love to hear if it works. I received a sensor cable and a new RM4 and tried to replicate the codes used elsewhere to read the values... but then found the RM4 I ordered was a RM4C Mini which isn't compatible with the sensor. In theory it'll work, but I'd be surprised if it does.

I've got another RM4 that's arriving in the country any day now.

CVHvisuals commented 4 years ago

I’ve been trying to figure out the syntax also for my sensor with the rm4 pro. I would just add “Aircon” as an accessory?

CVHvisuals commented 4 years ago

I added to the config: “name”: “Thermostat”, “type”: “air-conditioner”, “data”: { “temperatureDisplayUnits”: “F”, “temperatureUpdateFrequency”: 20 } }

(Requested temperature from device, waiting)

Is there a parameter I should add to the config?

CVHvisuals commented 4 years ago

Here is the log for the sensor:

[7/21/2020, 8:43:08 PM] [Broadlink RM] Bedroom TV getSwitchState: 1 [7/21/2020, 8:43:08 PM] [Broadlink RM] Air Cleaner getSwingMode: 0 [7/21/2020, 8:43:08 PM] [Broadlink RM] Air Cleaner getSwitchState: true [7/21/2020, 8:43:08 PM] [Broadlink RM] Air Cleaner getFanSpeed: 10 [7/21/2020, 8:43:08 PM] [Broadlink RM] Air Cleaner getRotationDirection: 0 [7/21/2020, 8:43:08 PM] [Broadlink RM] Bedroom Stereo getSwitchState: true [7/21/2020, 8:43:08 PM] [Broadlink RM] Bedroom temp getTargetTemperature: 26 [7/21/2020, 8:43:08 PM] [Broadlink RM] Bedroom temp getTargetHeatingCoolingState: 0 [7/21/2020, 8:43:08 PM] [Broadlink RM] Bedroom temp getCurrentHeatingCoolingState: 0 [7/21/2020, 8:43:11 PM] [Broadlink RM] Bedroom temp setTargetHeatingCoolingState: 0 (node:14729) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'off' of undefined at AirConAccessory.setTargetHeatingCoolingState (/usr/local/lib/node_modules/homebridge-broadlink-rm-pro/accessories/aircon.js:186:35) at AirConAccessory.setCharacteristicValue (/usr/local/lib/node_modules/homebridge-broadlink-rm-pro/node_modules/homebridge-platform-helper/accessory.js:139:10) at TargetHeatingCoolingState.emit (events.js:315:20) at TargetHeatingCoolingState.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/EventEmitter.js:60:38) at TargetHeatingCoolingState.Characteristic._this.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:369:23) at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Accessory.js:965:36 at Array.forEach (:null:null) at Bridge.Accessory._this._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Accessory.js:833:18) at HAPServer.emit (events.js:315:20) at HAPServer.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/EventEmitter.js:60:38) at HAPServer._this._handleCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/HAPServer.js:731:23) at IncomingMessage. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/HAPServer.js:240:39) at IncomingMessage.emit (events.js:315:20) at endReadableNT (_stream_readable.js:1221:12) at processTicksAndRejections (internal/process/task_queues.js:84:21)

(node:14729) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 33) [7/21/2020, 8:43:11 PM] [Broadlink RM] Bedroom temp setCurrentHeatingCoolingState: 0 [7/21/2020, 8:43:11 PM] [Broadlink RM] Bedroom temp setCurrentHeatingCoolingState: already 0 (no data sent - B)

kiwi-cam commented 4 years ago

The Air-conditioner accessory isn't really designed for be used as a thermostat. At the very least, you're going to have to define on and off hex codes - even if they're rubbish values. Check out the documentation here: https://lprhodes.github.io/slate/#air-conditioner

CVHvisuals commented 4 years ago

Thanks, unfortunately after a couple hours of trying parameters, no temp. Works in the Broadlink app.

Faisalthe01 commented 4 years ago

@kiwi-cam so I got myself a RM4 Mini, set it up using Broadlink app.

I used your BroadlinkJS RM4 Testing.

Homebridge was unable to start with error

 let packet = (rm4DeviceTypes[parseInt(this.deviceType, 16)] || rm4PlusDeviceTypes[parseInt(this.deviceType, 16)]) ? new Buffer([0x24]) : new Buffer([0x1]);
        ^

SyntaxError: Identifier 'packet' has already been declared
    at wrapSafe (internal/modules/cjs/loader.js:1072:16)
    at Module._compile (internal/modules/cjs/loader.js:1122:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)

so i removed the let packet = new Buffer([0x1]); from line 513 and Homebridge started and discovered my Broadlink RM Mini 4 S (648d).

However, it is not reading the temperature from it logs

[7/29/2020, 2:22:11 PM] [Broadlink RM] Heater addTemperatureCallbackToQueue (clearing previous callback, using existing temperature)
[7/29/2020, 2:22:11 PM] [Broadlink RM] Heater addTemperatureCallbackToQueue (requested temperature from device, waiting)
[7/29/2020, 2:22:16 PM] [Broadlink RM] Heater addTemperatureCallbackToQueue (requested temperature from device, waiting)
[7/29/2020, 2:22:21 PM] [Broadlink RM] Heater addTemperatureCallbackToQueue (clearing previous callback, using existing temperature)
[7/29/2020, 2:22:21 PM] [Broadlink RM] Heater addTemperatureCallbackToQueue (requested temperature from device, waiting)
[7/29/2020, 2:22:26 PM] [Broadlink RM] Heater addTemperatureCallbackToQueue (requested temperature from device, waiting)
[7/29/2020, 2:22:31 PM] [Broadlink RM] Heater addTemperatureCallbackToQueue (clearing previous callback, using existing temperature)
[7/29/2020, 2:22:31 PM] [Broadlink RM] Heater addTemperatureCallbackToQueue (requested temperature from device, waiting)
[7/29/2020, 2:22:36 PM] [Broadlink RM] Heater addTemperatureCallbackToQueue (requested temperature from device, waiting)
kiwi-cam commented 4 years ago

Doh! Thanks @Faisalthe01 line 513 should've been commented out. This is fixed in homebridge-broadlink-rm-pro@4.2.9-beta.2

I should be able to take a good look at the temperature issue in the next couple of weeks.

kiwi-cam commented 4 years ago

homebridge-broadlink-rm-pro@beta now supports the RM4 temperature sensor. This will move to the main branch soon. Please try it out and let me know if there are any issues.

Faisalthe01 commented 4 years ago

@kiwi-cam , works like a charm. thanks mate.

Faisalthe01 commented 4 years ago

@kiwi-cam , just a thing i noticed it is reporting a bit higher temperature than my Aqara temperature sensor and they are sitting side by side. My Aqara is showing 17c (which is correct i think for a cold winter morning) while my Broadlink RM Mini 4 is showing 25c in logs and Home app. could it be related to Broadlink's sensor issue itself?

CVHvisuals commented 4 years ago

can you share your config for the temp sensor please. I having some troubles figuring it out. thanks

Faisalthe01 commented 4 years ago

can you share your config for the temp sensor please. I having some troubles figuring it out. thanks

                    "name": "Heater",
                    "type": "air-conditioner",
                    "ignoreTemperatureWhenOff": true,
                    "host": "192.168.0.161",
                    "temperatureUpdateFrequency": 60,
                    "maxTemperature": 27,
                    "minTemperature": 15,
                    "preventResendHex": false,
                    "temperatureAdjustment": -7.5,
                    "disableLogs": true,

that's my config's header for my aircon. you need to get rid of any update temperature from file or any other temperature config from it only then it will pick up the temp from your broadlink

kiwi-cam commented 4 years ago

@kiwi-cam , just a thing i noticed it is reporting a bit higher temperature than my Aqara temperature sensor and they are sitting side by side. My Aqara is showing 17c (which is correct i think for a cold winter morning) while my Broadlink RM Mini 4 is showing 25c in logs and Home app. could it be related to Broadlink's sensor issue itself?

I think you're right. The calculations to combine two fields appear to have changed. I'm just testing what I think is the correct calculation.

kiwi-cam commented 4 years ago

The latest BETA (homebridge-broadlink-rm-pro@4.3.0-beta.3) has the corrected temperature calculation. I've only had a couple of degrees of variation but it appears to be matching and moving with my Raspberry Pi w1 thermometer.

RM Temp: 21.69 w1 Temp: 21.625

RM Temp: 22 w1 Temp: 22.062

RM Temp: 23.33 w1 Temp: 23.25

CVHvisuals commented 4 years ago

I sure did have a time getting the sensor to not crash my HB. I made it populate now, I had to setup the sensor with the broadlink app. I am using the same settings as I posted above previously. I only can see the temperature in "C". I have set the "temperatureDisplayUnits" : "F", but no success. The config that Faisalthe01 provided cause a "No response from HB, although I can still toggle the switches. I should note I am running HB on a Mac mini.

Faisalthe01 commented 4 years ago

I sure did have a time getting the sensor to not crash my HB. I made it populate now, I had to setup the sensor with the broadlink app. I am using the same settings as I posted above previously. I only can see the temperature in "C". I have set the "temperatureDisplayUnits" : "F", but no success. The config that Faisalthe01 provided cause a "No response from HB, although I can still toggle the switches. I should note I am running HB on a Mac mini.

Post your full aircon config.

CVHvisuals commented 4 years ago

“name”: “Thermostat”, “type”: “air-conditioner”, “data”: { “temperatureDisplayUnits”: “F”, “temperatureUpdateFrequency”: 20 } }

Faisalthe01 commented 4 years ago

“name”: “Thermostat”, “type”: “air-conditioner”, “data”: { “temperatureDisplayUnits”: “F”, “temperatureUpdateFrequency”: 20 } }

temperatureDisplayUnits and temperatureUpdate does not belong under data.

Have a look at Kiwi-Cam’s config: https://github.com/kiwi-cam/MyHomeBridge/blob/master/var/homebridge/config.json

deeloke commented 4 years ago

Works! Added it to my existing air conditioner Accessory. Air-conditioner now reports temperature from cable. But air-conditioner goes offline more often and I sometimes need to refresh room before I can read temp/ access aircon (more than before). Any chance we can add cable as a sensor separate from an existing air con accessory?

Faisalthe01 commented 4 years ago

Works! Added it to my existing air conditioner Accessory. Air-conditioner now reports temperature from cable. But air-conditioner goes offline more often and I sometimes need to refresh room before I can read temp/ access aircon (more than before). Any chance we can add cable as a sensor separate from an existing air con accessory?

Try disabling the logs for aircon accessory

masterfordev commented 4 years ago

Hi, first of all I'd like to thank you for your work. I tested the Beta 3 with my RM 4 Mini with the temperature and humidity sensors. They worked perfectly for me, only a 2.5 degree variation but I adjusted it.

Just one question, this command i have to run with sudo?

npm install -g homebridge-broadlink-rm-pro@beta

because i had to did it.. if i dont do with sudo this send me an error.

Thanks for all.. Waiting for the official release.

jsalexjs commented 4 years ago

Hmm,I'm still having issues using the latest beta. (I'm using degrees Celsius on my zircon in case that's relevant) But I keep getting this "[Broadlink RM] [INFO] Reported temperature (-1) is too low, setting to minTemperature (9)."

Any ideas? Using an rm4 mini with the temperature sensor cable.

masterfordev commented 4 years ago

Hmm,I'm still having issues using the latest beta. (I'm using degrees Celsius on my zircon in case that's relevant) But I keep getting this "[Broadlink RM] [INFO] Reported temperature (-1) is too low, setting to minTemperature (9)."

Any ideas? Using an rm4 mini with the temperature sensor cable.

Can you share your config?

masterfordev commented 4 years ago

Is possible display the humidity as an sensor room in the Home App?

kiwi-cam commented 4 years ago

The humidity sensor has been added in the latest BETA. Will be in v4.3.3

Faisalthe01 commented 4 years ago

The humidity sensor has been added in the latest BETA. Will be in v4.3.3

Thanks @kiwi-cam, will give it a try. Any chance to get the current humidity from the RM4 into Humidifier accessory?

masterfordev commented 4 years ago

The humidity sensor has been added in the latest BETA. Will be in v4.3.3

Thanks, this work, but is not possible display that accessory here?: IMG_258B2882AFBC-1 In the state of the room.

masterfordev commented 4 years ago

and I disabled the logs but they still appear Captura de Pantalla 2020-09-26 a la(s) 11 47 05 p m

will hide it in the next beta? and maybe you can set an option to set the updateFrequency for humidity sensor too, like the emperatureUpdateFrequency...

kiwi-cam commented 4 years ago

Sorry, that’s an extra log I threw in for troubleshooting. I’ll tidy that up.

As far as I know there’s no way to present the humidity. That’s down to what HomeKit does with the information- which isn’t much.

kiwi-cam commented 4 years ago

Just checked and Humidity is available in automations in the Eve app: D2D10BE6-F961-4158-A8F3-64924515B556

Faisalthe01 commented 4 years ago

@kiwi-cam The humidity works great. If you want to add humidity as a separate sensor like @masterfordev asked above you will need to have one more accessory which is Humidity Sensor accessory like you created an accessory for temperature Sensor

https://github.com/Faisalthe01/homebridge-broadlink-rm-heater/blob/master/accessories/humidSensor.js

then add this in your config.json

                {
                    "name": "Dining Humidity",
                    "type": "humidSensor",
                    "host": "192.168.0.161",
                    "temperatureUpdateFrequency": 60,
                    "disableLogs": true
                },

then the humidity will appear under the temp when you move both temp and humid in same room, this is how it is display in iOS 14 humid

And if you have it in a room without a temp sensor then it appears like this EA930EE5-8C9F-4A80-9518-AEE332BB1B0C

Faisalthe01 commented 4 years ago

@kiwi-cam if you decide to add the Humidity Sensor accessory type then no need to add Current Humidity to Humidifier from Broadlink but a way to remove Current Relative Humidity from the Humidifier accessory so Home app does not show 2 humidity values, left from Broadlink which is correct and real and the right one is from Humidifier Accessory which is bogus.

5D7EFF88-50EE-48CB-A178-FFBFEB9E0906

kiwi-cam commented 4 years ago

@kiwi-cam if you decide to add the Humidity Sensor accessory type then no need to add Current Humidity to Humidifier from Broadlink but a way to remove Current Relative Humidity from the Humidifier accessory so Home app does not show 2 humidity values, left from Broadlink which is correct and real and the right one is from Humidifier Accessory which is bogus.

Looks like he's used my code, and included the "noHumidity" config option which will suit this case nicely. I'll try to take a look at including this tomorrow.

Faisalthe01 commented 4 years ago

@kiwi-cam if you decide to add the Humidity Sensor accessory type then no need to add Current Humidity to Humidifier from Broadlink but a way to remove Current Relative Humidity from the Humidifier accessory so Home app does not show 2 humidity values, left from Broadlink which is correct and real and the right one is from Humidifier Accessory which is bogus.

Looks like he's used my code, and included the "noHumidity" config option which will suit this case nicely. I'll try to take a look at including this tomorrow.

Hey @kiwi-cam bud, Sorry i didn't get what you mean here. if you are talking about a separate Humidity Sensor accessory then yes, i used your code from Temperature Sensor and converted it to Humidity https://github.com/Faisalthe01/homebridge-broadlink-rm-heater/blob/master/accessories/humidSensor.js you can add this as one of the accessory and then the Humidity will be a separate accessory too in Home app.

I'm trying to remove the bogus humidity information from the Humidifier-Dehumidifier accessory so it can be only show one value of current humidity but your code from "NoHumdity" did not work very well in that or maybe i did something wrong.

kiwi-cam commented 4 years ago

I clearly typed that on my phone while doing other things. Sorry, I didn't get what I meant either.

I've just been taking a look at the Humidifier-Dehumidifer. That's going to be a bigger job than I expected with those bogus values being used. We'll need to implement setting actual humidity values similar to all the different temperature hex codes in on the aircon accessory.

We'll see how busy my week gets. If you crack it, let me know and I'll take a look at integrating it.

kiwi-cam commented 4 years ago

Great tip @Faisalthe01. I added “noHumidity” to my AC and added a HumiditySensor and it looks great: 0A985ED4-AC70-4B76-BDEC-21DF670F1194

New Beta coming with a separate humiditySensor.

Faisalthe01 commented 4 years ago

Great tip @Faisalthe01. I added “noHumidity” to my AC and added a HumiditySensor and it looks great: 0A985ED4-AC70-4B76-BDEC-21DF670F1194

New Beta coming with a separate humiditySensor.

it sure looks nice. I see you have only used the necessary code in your version of HumiditySensor.js, which is great. thank you.

regarding the Humidifier accessory, i think the Current Humidity is mandatory so no way to remove it and only way to make it right is to read and publish from Broadlink sensor like you did in AC for Temp and Humidity.

jsalexjs commented 3 years ago

You need the correct cable with the temperature sensor.

Sent from my iPhone

On 14 Jun 2021, at 7:13 pm, SergeyFIL @.***> wrote:

 After adding humiditySensor and temperatureSensor with IP of my Broadlink RM4 mini I've got an error:

This plugin generated a warning from the characteristic 'Current Relative Humidity': characteristic value expected valid finite number and received "undefined".

How did you fixed it?

Because I don't have any data in HomeKit app

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.