AlexxIT / XiaomiGateway3

Home Assistant custom component for control Xiaomi Multimode Gateway (aka Gateway 3), Xiaomi Multimode Gateway 2, Aqara Hub E1 on default firmwares over LAN
https://github.com/AlexxIT/Blog
MIT License
2.47k stars 348 forks source link

add support for xiaomi.sensor_occupy.03 #1369

Closed CharmingCheung closed 6 months ago

CharmingCheung commented 6 months ago

image

AlexxIT commented 6 months ago

Thanks!

kei81131 commented 6 months ago

Updated battery sensor and added entities IMG_4041

{
    # https://home.miot-spec.com/spec/xiaomi.sensor_occupy.03
    18051: ["Xiaomi", "Occupancy Sensor", "XMOSB01XS", "xiaomi.sensor_occupy.03"],
    "spec": [
        # main sensors
        BoolConv("occupancy", "binary_sensor", mi="2.p.1078"),#Tested
        BaseConv("illuminance", "sensor", mi="2.p.1005"),#Tested
        # other sensors
        BaseConv("battery", "sensor", mi="3.p.1003"),
        BaseConv("has_someone_duration", "sensor", mi="2.p.1081"),
        BaseConv("no_one_duration", "sensor", mi="2.p.1082"),

    ],
}, 
CharmingCheung commented 6 months ago

Updated battery sensor and added entities IMG_4041

{
    # https://home.miot-spec.com/spec/xiaomi.sensor_occupy.03
    18051: ["Xiaomi", "Occupancy Sensor", "XMOSB01XS", "xiaomi.sensor_occupy.03"],
    "spec": [
        # main sensors
        BoolConv("occupancy", "binary_sensor", mi="2.p.1078"),#Tested
        BaseConv("illuminance", "sensor", mi="2.p.1005"),#Tested
        # other sensors
        BaseConv("battery", "sensor", mi="3.p.1003"),
        BaseConv("has_someone_duration", "sensor", mi="2.p.1081"),
        BaseConv("no_one_duration", "sensor", mi="2.p.1082"),

    ],
}, 

I also noticed the has_someone_duration and no_one_duration parameters. However, this is because the device is battery-powered and provides Mi Home users with a rough time estimate as a reference. Since HA integrates this device through XiaomiGateway3 and receives real-time status updates, it is entirely possible to calculate a more precise duration by fetching the last_changed attribute of occupancy entity. Therefore, I decided not to include these two parameters initially. As for the battery, I couldn't test it initially due to the low reporting frequency. I later tried adding "sensor" and tested it, and you seem to be correct.

AlexxIT commented 2 months ago

https://github.com/AlexxIT/XiaomiGateway3/releases/tag/v4.0.6