openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.58k forks source link

[miio] Please support Qingping Air Monitor Lite (cgllc.airm.cgdn1) #10152

Closed joeberlin123 closed 3 years ago

joeberlin123 commented 3 years ago

@marcelrv Please support Qingping Air Monitor Lite (cgllc.airm.cgdn1)

See Miot specs: https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-monitor:0000A008:cgllc-cgdn1:1

And the integration in python-miio for reference https://github.com/rytilahti/python-miio/commit/78f8beee13d9fbd5f2b1a11a311f736b41a2ba06

openhab-bot commented 3 years ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/xiaomi-robot-vacuum-binding/31317/1822

marcelrv commented 3 years ago

@joeberlin123 Can you download the json file in the linked above repository and save it to your conf/misc/miio folder. Than restart the binding, the channels should now be visible. See the binding readme for more details on adding local db files if it does not work. Note: this requires a recent OH version (OH3) to see the channels properly.

Can you share a debug log of the refresh and feedback if the channels repond well.

joeberlin123 commented 3 years ago

@marcelrv Thank you very much. It took me a moment to test because I didn't have an OH3 instance yet. In my tests everything worked perfectly. Do you still need debug logfiles then? If so can you please give me a short hint how to create the logfiles with debug level. Thank you very much. Regards Jörg

marcelrv commented 3 years ago

@marcelrv Thank you very much. It took me a moment to test because I didn't have an OH3 instance yet. In my tests everything worked perfectly. Do you still need debug logfiles then? If so can you please give me a short hint how to create the logfiles with debug level. Thank you very much. Regards Jörg

@joeberlin123 Yes please. See the PR

kovaga commented 3 years ago

@joeberlin123 Can you download the json file in the linked above repository and save it to your conf/misc/miio folder. Than restart the binding, the channels should now be visible. See the binding readme for more details on adding local db files if it does not work. Note: this requires a recent OH version (OH3) to see the channels properly.

@marcelrv Would the binding for the cgdn1 work with OH2?

marcelrv commented 3 years ago

@kovaga this will partially work with OH2.5 You would need to edit it e.g.--> Change the types that have Number:XXX to Number All the mappings would not work automatically, but if you make them manually (from the examples in the binding readme) than you should have mapped values. Others... who knows... but I would expect most of it works to some extend. I would say try it, don't worry you won't break anything

kovaga commented 3 years ago

@marcelrv I am on 2.5.12-1 So I have downloaded the cgllc.airm.cgdn1-miot.json and placed it in /etc/openhab2/misc/miio, but I dont think its the right place for it, as I am getting the following log entry. [io.internal.handler.MiIoBasicHandler] - Database entry for model 'cgllc.airm.cgdn1' cannot be found.

Where should I store that json file?

marcelrv commented 3 years ago

Can you restart OH... I expect it display the proper location for your installation in the debug logging

kovaga commented 3 years ago

Indeed, it did display the location and in fact picked up the file this time.

2021-04-14 15:40:56.049 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:basic:cgdn1' (miio:basic)
2021-04-14 15:40:56.049 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Building Channel Structure for miio:basic:cgdn1 - Model: cgllc.airm.cgdn1
2021-04-14 15:40:56.050 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Using device database: /etc/openhab2/misc/miio/cgllc.airm.cgdn1-miot.json for device cgllc.airm.cgdn1
2021-04-14 15:40:56.053 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Current thing channels miio:basic:cgdn1:network#ssid, type: miio:ssid
2021-04-14 15:40:56.053 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Current thing channels miio:basic:cgdn1:network#bssid, type: miio:bssid
2021-04-14 15:40:56.054 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = actions, friendlyName = Actions, type = String, channelType = , ChannelGroup = , channel = actions, property = , refresh = false]
2021-04-14 15:40:56.054 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = relative_humidity, friendlyName = Environment - Relative Humidity, type = Number:Dimensionless, channelType = , ChannelGroup = , channel = relative_humidity, property = relative-humidity, refresh = true]
2021-04-14 15:40:56.054 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = pm2_5_density, friendlyName = Environment - PM2 5 Density, type = Number, channelType = , ChannelGroup = , channel = pm2_5_density, property = pm2.5-density, refresh = true]
2021-04-14 15:40:56.054 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = pm10_density, friendlyName = Environment - PM10 Density, type = Number, channelType = , ChannelGroup = , channel = pm10_density, property = pm10-density, refresh = true]
2021-04-14 15:40:56.054 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = temperature, friendlyName = Environment - Temperature, type = Number:Temperature, channelType = , ChannelGroup = , channel = temperature, property = temperature, refresh = true]
2021-04-14 15:40:56.055 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = co2_density, friendlyName = Environment - CO2 Density, type = Number:Dimensionless, channelType = , ChannelGroup = , channel = co2_density, property = co2-density, refresh = true]
2021-04-14 15:40:56.055 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = battery_level, friendlyName = Battery - Battery Level, type = Number:Dimensionless, channelType = , ChannelGroup = , channel = battery_level, property = battery-level, refresh = true]
2021-04-14 15:40:56.055 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = charging_state, friendlyName = Battery - Charging State, type = Number, channelType = , ChannelGroup = , channel = charging_state, property = charging-state, refresh = true]
2021-04-14 15:40:56.055 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = voltage, friendlyName = Battery - Voltage, type = Number, channelType = , ChannelGroup = , channel = voltage, property = voltage, refresh = true]
2021-04-14 15:40:56.055 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = mac, friendlyName = Mac - Mac, type = String, channelType = , ChannelGroup = , channel = mac, property = mac, refresh = true]
2021-04-14 15:40:56.055 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = start_time, friendlyName = Settings - Start Time, type = Number, channelType = , ChannelGroup = , channel = start_time, property = start-time, refresh = true]
2021-04-14 15:40:56.055 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = end_time, friendlyName = Settings - End Time, type = Number, channelType = , ChannelGroup = , channel = end_time, property = end-time, refresh = true]
2021-04-14 15:40:56.055 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = monitoring_frequency, friendlyName = Settings - Monitoring Frequency, type = Number:Time, channelType = , ChannelGroup = , channel = monitoring_frequency, property = monitoring-frequency, refresh = true]
2021-04-14 15:40:56.056 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = screen_off, friendlyName = Settings - Screen Off, type = Number:Time, channelType = , ChannelGroup = , channel = screen_off, property = screen-off, refresh = true]
2021-04-14 15:40:56.056 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = device_off, friendlyName = Settings - Device Off, type = Number:Time, channelType = , ChannelGroup = , channel = device_off, property = device-off, refresh = true]
2021-04-14 15:40:56.056 [DEBUG] [io.internal.handler.MiIoBasicHandler] - properties [ Channel = tempature_unit, friendlyName = Settings - Tempature Unit, type = String, channelType = , ChannelGroup = , channel = tempature_unit, property = tempature-unit, refresh = true]
2021-04-14 15:40:56.056 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Current thing channels added: 16

However it is unable to get the values

2021-04-14 15:43:41.183 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:basic:cgdn1' (miio:basic)
2021-04-14 15:43:41.183 [DEBUG] [internal.handler.MiIoAbstractHandler] - Skipping periodic update for 'miio:basic:cgdn1'. Thing Status CONFIGURATION_ERROR
2021-04-14 15:43:41.183 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":19,"method":"miIO.info","params":[]} -> 192.168.9.148 (Device: 0793XXXX token: 7746785AXXXXXXXXXXXXXXXX4F72XXXX Queue: 8)
2021-04-14 15:43:41.679 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Communication error for Mi device at 192.168.9.148: Receive timed out
2021-04-14 15:43:41.679 [DEBUG] [nal.transport.MiIoAsyncCommunication] - No response from device 0793XXXX at 192.168.9.148 for command {"id":11,"method":"get_properties","params":[{"did":"monitoring-frequency","siid":9,"piid":4}]}.
2021-04-14 15:43:41.679 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping 0793D308 (192.168.9.148)
2021-04-14 15:43:41.705 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping 0793D308 (192.168.9.148) success
2021-04-14 15:43:41.705 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for cgdn1 type: GET_PROPERTIES, result: {}, fullresponse: {"error":"No Response"}
2021-04-14 15:43:41.706 [DEBUG] [internal.handler.MiIoAbstractHandler] - Error received: "No Response"

Thats how i have it configured in things and items.

Thing miio:basic:cgdn1       "Air Monitor Lite"    [host="192.168.9.148", token="774678XXXXXX25XXXX", deviceId="cgdn1", model="cgllc.airm.cgdn1"]

items
Number                  pm2_5_density           "Environment - PM2 5 Density"                   (G_airm)                {channel="miio:basic:cgdn1:pm2_5_density"}
Number                  pm10_density            "Environment - PM10 Density"                    (G_airm)                {channel="miio:basic:cgdn1:pm10_density"}
Number                  temperature             "Environment - Temperature"                     (G_airm)                {channel="miio:basic:cgdn1:temperature"}
Number                  co2_density             "Environment - CO2 Density"                     (G_airm)                {channel="miio:basic:cgdn1:co2_density"}

I can also see the UDP trafic exchange between OH and CGDN1

16:04:26.247026 IP 192.168.9.12.51064 > 192.168.9.148.54321: UDP, length 32
16:04:26.302120 IP 192.168.9.148.54321 > 192.168.9.12.51064: UDP, length 32
daemon110282 commented 2 years ago

@marcelrv Hello. I am on 2.5.12. Downloaded json and org.openhab.binding.miio-2.5.12-SNAPSHOT. I see what connection success, data received to openhab, but not updated items. In PaperUI i don't see actual value item. Can you help me?

2021-10-25 20:41:06.885 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":85,"method":"get_properties","params":[{"did":"temperature","siid":3,"piid":7}]} -> 192.168.0.158 (Device: XXXXX token: XXXX Queue: 3) 2021-10-25 20:41:06.889 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Skip refresh of channel battery_level for miio:basic:airm as it is not linked 2021-10-25 20:41:06.891 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Skip refresh of channel charging_state for miio:basic:airm as it is not linked 2021-10-25 20:41:07.315 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for airm type: GET_PROPERTIES, result: [{"did":"temperature","siid":3,"piid":7,"code":0,"value":24.6000}], fullresponse: {"id":85,"result":[{"did":"temperature","siid":3,"piid":7,"code":0,"value":24.6000}],"exe_time":40} 2021-10-25 20:41:07.317 [DEBUG] [io.internal.handler.MiIoBasicHandler] - No update logic for channeltype 'Number:Temperature' 2021-10-25 20:41:07.546 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for airm type: MIIO_INFO, result: {"life":2813962,"uid":XXXXX,"model":"cgllc.airm.cgdn1","token":"XXXXX","ipflag":1,"fw_ver":"2.1.7_0382","mcu_fw_ver":"0383","miio_ver":"0.0.9","hw_ver":"esp32","mmfree":4184912,"mac":"XXXX","wifi_fw_ver":"v4.0.1-468-gba0b4be54f-dirty","ap":{"ssid":"XXXX","bssid":"XXXXX","rssi":-52,"primary":4},"netif":{"localIp":"XXXX","mask":"255.255.255.0","gw":"192.168.0.1"}}, fullresponse: {"id":87,"result":{"life":2813962,"uid":XXXXX,"model":"cgllc.airm.cgdn1","token":"XXXXX","ipflag":1,"fw_ver":"2.1.7_0382","mcu_fw_ver":"0383","miio_ver":"0.0.9","hw_ver":"esp32","mmfree":4184912,"mac":"XXXX","wifi_fw_ver":"v4.0.1-468-gba0b4be54f-dirty","ap":{"ssid":"XXX","bssid":"XXXX","rssi":-52,"primary":4},"netif":{"localIp":"XXX","mask":"255.255.255.0","gw":"192.168.0.1"}},"exe_time":40}

marcelrv commented 2 years ago

Yes, as indicated before

@kovaga this will partially work with OH2.5 You would need to edit it e.g.--> Change the types that have Number:XXX to Number All the mappings would not work automatically, but if you make them manually (from the examples in the binding readme) than you should have mapped values. Others... who knows... but I would expect most of it works to some extend. I would say try it, don't worry you won't break anything

The line 2021-10-25 20:41:07.317 [DEBUG] [io.internal.handler.MiIoBasicHandler] - No update logic for channeltype 'Number:Temperature' indicates indeed that it is not working with the current version. You can try to remove the :Temperature part from the channeltype, (or from any channel that has something number:someType, 2.5 only knows just Number) than it probaly shows the value in 2.5.x... better: update to 3.1

daemon110282 commented 2 years ago

@marcelrv thanks! Change type to Number in json and all works!