Closed pplucky closed 3 years ago
@pplucky Thanks for opening a separate feature request for the WX08ZM. The state property really calls for a binary sensor to publish the on/off state properly. I need a good example how to publish some float values like battery and mosquito tablet alongside with the state. I think binary sensor has also support for float values, but I'll have to read up on this. Meanwhile you can test the code as is in ahpohl/esphome:xiaomi_complete
The state property really calls for a binary sensor to publish the on/off state properly
Yep, that's true. Let me know if you need any testing there.
Meanwhile you can test the code as is in ahpohl/esphome:xiaomi_complete
Looking good:
1 LYWSD03MMC,2 WX08ZM and 1 LYWSDCGQ
Great its still working! Yesterday I worked on the documentation and updated the pull requests. Its nearly finished. Once thats done, I might produce a version of the WX08ZM as a binary sensor so it will show the on/off state properly in HA. I wonder how @Magalex2x14 has implemented the sensor in HA (no time to look at the code yet). I think there is a new mitemp_bt beta out which you could try as well (the off state icon should show yellow and the on state blue).
HA has a separate sensor entity class for this. All I had to do was to convert the state of the sensor to a Boolean type. The device_class for this entity I select from the dictionary, based on the type of device. However, in the case of my custom component, there is one thin point related to the delay in changing the state of an entity in HA due to the periodic nature of the work of my platform (details here, if interested).
I have a question. Can this device be turned on/off using BLE?
If this can be done from the MiHome application, then it can. The only thing that it is usually done through the BLE connection, which is not implemented in ESPHome, if I remember correctly (correct me if I am mistaken).
@pplucky I updated the WX08ZM to a hybrid sensor
and binary_sensor
component. Now the power status in HA looks much nicer (on/off rather than 0/1) and the color of the symbol changes as well. You can pull the updated code from ahpohl/eshome:xiaomi_wx08zm until is has been merged with ahpohl/eshome:dev.
In order to compile, you need to have both sensor
and binary_sensor
in your config:
sensor:
binary_sensor:
- platform: xiaomi_wx08zm
name: "WX08ZM Mosquito Repellent"
mac_address: "74:a3:4a:b5:07:34"
tablet:
name: "WX08ZM Tablet Resource"
battery_level:
name: "WX08ZM Battery Level"
@pplucky I updated the WX08ZM to a hybrid
sensor
andbinary_sensor
component. Now the power status in HA looks much nicer (on/off rather than 0/1) and the color of the symbol changes as well. You can pull the updated code from ahpohl/eshome:xiaomi_wx08zm until is has been merged with ahpohl/eshome:dev.In order to compile, you need to have both
sensor
andbinary_sensor
in your config:sensor: binary_sensor: - platform: xiaomi_wx08zm name: "WX08ZM Mosquito Repellent" mac_address: "74:a3:4a:b5:07:34" tablet: name: "WX08ZM Tablet Resource" battery_level: name: "WX08ZM Battery Level"
Looking good:
As expected, the binary sensor doesn't update immediately once device is turned on/off, but it is quite acceptable I think.
Edit (with added template sensor to provide estimate of days for tablet duration):
Currently in HA, I may consider moving those to esphome also.
@pplucky Thank you very much for testing the hybrid binary_sensor / sensor code.
I merged the changes with ahpohl/eshome:dev and updated the documentation. The preview is here.
Guys, installed tested and working. But are any way to switch on off device?
Guys, installed tested and working. But are any way to switch on off device?
Nope. Esphome connection is passive BLE and in theory that would need pairing an active BT connection to do it, as Mi Home app does it.
Guys, installed tested and working. But are any way to switch on off device?
Nope. Esphome connection is passive BLE and in theory that would need pairing an active BT connection to do it, as Mi Home app does it.
Understand... And there are no way to implement it? like a mqtt used in zigbee devices. This is the step missing to get full control 😊
@pplucky I guess this issue can be closed: https://esphome.io/components/sensor/xiaomi_ble.html#wx08zm
Describe the problem you have/What new integration you would like
Add support for the Xiaomi Mijia Mosquito Repellent Smart Version (Model WX08ZM)
Please describe your use case for this integration and alternatives you've tried:
Knowing the battery left, tablet remaining and working status would allow not to use Xiaomi Mi Home while being nearby. Having it running in an ESP32 with BT would be great
Additional context
Some payload investigation already done here.
Working prototype here.