al-one / hass-xiaomi-miot

Automatic integrate all Xiaomi devices to HomeAssistant via miot-spec, support Wi-Fi, BLE, ZigBee devices. 小米米家智能家居设备接入Hass集成
https://miot-spec.com
Apache License 2.0
4.45k stars 623 forks source link

zhimi.heater.nb1 indicator_light wrong behaviour #469

Closed FrancYescO closed 2 years ago

FrancYescO commented 2 years ago

zhimi.heater.nb1

image

Controlling this entity causes wrong behaviours: Turning the switch on or off will instead turn the heater on or off and not just the LED lights indicator changing brightness is likely inverted: from 1 to 49 = LED in HIGH brightness mode = attribute Indicator light.brightness 0 from 50 to 99 = LED in LOW brightness mode = attribute Indicator light.brightness 1 100 = LED off (like screenshot above) = attribute Indicator light.brightness 2

al-one commented 2 years ago

https://home.miot-spec.com/spec/zhimi.heater.nb1

{
    "iid":6,
    "type":"urn:miot-spec-v2:service:indicator-light:00007803:zhimi-nb1:1",
    "description":"Indicator Light",
    "properties":[
        {
            "iid":1,
            "type":"urn:miot-spec-v2:property:brightness:0000000D:zhimi-nb1:1",
            "description":"Brightness",
            "format":"uint8",
            "access":["read", "write", "notify"],
            "value-range":[0, 2, 1] // 0:high 1:low 2:close
        }
    ]
}
FrancYescO commented 2 years ago

thanks, i've notice also another little thing: a default entity switch is created with nothing specific on the entity id neither on name (will get the name of the device), i've noticed that this entity will control the "Return to middle" function (for the default on-off there is an entity called switch.zhimi_nb1_897a_switch_status)

image image

and finally i have this issue, that idk if depends on your integration specifilcally: when trying to turn on-off via alexa (using the climate.* entity), it work but when turning off i get this exception (and alexa voice respond with an error message while is not):

2022-03-11 09:15:51 ERROR (MainThread) [homeassistant.components.alexa.capabilities] climate.zhimi_nb1_897a_heater (<class 'homeassistant.core.State'>) has unsupported state value 'fan not swing'
2022-03-11 09:15:51 ERROR (MainThread) [homeassistant.components.alexa.smart_home] Uncaught exception processing Alexa Alexa.PowerController/TurnOff request (climate.zhimi_nb1_897a_heater)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/alexa/smart_home.py", line 43, in async_handle_message
    response.merge_context_properties(directive.endpoint)
  File "/usr/src/homeassistant/homeassistant/components/alexa/messages.py", line 189, in merge_context_properties
    for prop in endpoint.serialize_properties():
  File "/usr/src/homeassistant/homeassistant/components/alexa/entities.py", line 323, in serialize_properties
    yield from interface.serialize_properties()
  File "/usr/src/homeassistant/homeassistant/components/alexa/capabilities.py", line 246, in serialize_properties
    prop_value = self.get_property(prop_name)
  File "/usr/src/homeassistant/homeassistant/components/alexa/capabilities.py", line 1070, in get_property
    raise UnsupportedProperty(name)
homeassistant.components.alexa.errors.UnsupportedProperty: thermostatMode

when turning ON:

2022-03-11 09:16:22 ERROR (MainThread) [homeassistant.components.alexa.capabilities] climate.zhimi_nb1_897a_heater (<class 'homeassistant.core.State'>) has unsupported state value 'fan not swing'
2022-03-11 09:16:22 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/alexa/state_report.py", line 94, in async_entity_state_listener
    alexa_properties = list(alexa_changed_entity.serialize_properties())
  File "/usr/src/homeassistant/homeassistant/components/alexa/entities.py", line 323, in serialize_properties
    yield from interface.serialize_properties()
  File "/usr/src/homeassistant/homeassistant/components/alexa/capabilities.py", line 246, in serialize_properties
    prop_value = self.get_property(prop_name)
  File "/usr/src/homeassistant/homeassistant/components/alexa/capabilities.py", line 1070, in get_property
    raise UnsupportedProperty(name)
homeassistant.components.alexa.errors.UnsupportedProperty: thermostatMode
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/alexa/state_report.py", line 94, in async_entity_state_listener
    alexa_properties = list(alexa_changed_entity.serialize_properties())
  File "/usr/src/homeassistant/homeassistant/components/alexa/entities.py", line 323, in serialize_properties
    yield from interface.serialize_properties()
  File "/usr/src/homeassistant/homeassistant/components/alexa/capabilities.py", line 246, in serialize_properties
    prop_value = self.get_property(prop_name)
  File "/usr/src/homeassistant/homeassistant/components/alexa/capabilities.py", line 1070, in get_property
    raise UnsupportedProperty(name)
homeassistant.components.alexa.errors.UnsupportedProperty: thermostatMode

i think also a default generated entity that keeps track of the Warm/Hot mode is usefull, actually the only way to change this mode is using this dropdown from the climate entity page:

image
al-one commented 2 years ago

has unsupported state value 'fan not swing'

This component can't do anything about it.

FrancYescO commented 2 years ago

Just tried last release 0.5.4 the behaviour of light is still a little confusing:

FrancYescO commented 2 years ago

has unsupported state value 'fan not swing'

This component can't do anything about it.

Is possible to report, instead of 'fan not swing' and 'fan swing' status (preset) the operation or fan mode, that is more indicative of the status of the heater?

schneivo77 commented 2 years ago

Hi, the zhimi.airpurifier.za1 has the same indicator light behaviour. So the light switch turns on/off the device instead of the light and brightness isn't working correctly.

image

al-one commented 2 years ago

@schneivo77 Try master branch.

schneivo77 commented 2 years ago

Hi @al-one,

thanks for the fix! Unfortunately it doesn't work correctly at the moment.

Light status is always 'on'. When the light on the airpurifier is on and I click the switch in the hassio UI, it turns off on the device but in the UI it still shows 'on' and I'm not able to turn it back on via the UI.

image

al-one commented 2 years ago

Try master branch again.

schneivo77 commented 2 years ago

Seems to work correctly now! Thank you! 👍