Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zhimi.heater.na1 climate entity problems #75

Closed
blakadder opened this issue May 6, 2021 · 4 comments
Closed

zhimi.heater.na1 climate entity problems #75

blakadder opened this issue May 6, 2021 · 4 comments

Comments

@blakadder
Copy link
Contributor

for model zhimi.heater.na1

In Home Assistant when switching the climate entity to mode "Auto" is reverts to empty and the entity state in HA state machine shows as being in mode fan not swing or fan swing. If a device is recognised as a heater it should have "heat" and "off" modes.

image
image

For this specific model the property urn:miot-spec-v2:property:mode:00000008:zhimi-na1:1 should be reported as swing mode "SWING_x" instead of presets.

There are also errors in HA logs:

2021-05-06 11:50:44 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.bathroom_heater_physical_controls_locked fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 316, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 524, in async_device_update
    raise exc
  File "/config/custom_components/xiaomi_miot/__init__.py", line 1154, in async_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_miot/switch.py", line 138, in update
    super().update()
  File "/config/custom_components/xiaomi_miot/__init__.py", line 1188, in update
    super().update()
  File "/config/custom_components/xiaomi_miot/__init__.py", line 1139, in update
    attrs = self._parent.device_state_attributes or {}
  File "/config/custom_components/xiaomi_miot/__init__.py", line 497, in device_state_attributes
    ext = self.state_attributes or {}
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 266, in state_attributes
    data[ATTR_PRESET_MODE] = self.preset_mode
  File "/config/custom_components/xiaomi_miot/climate.py", line 386, in preset_mode
    acm = -1 if acm is None else int(acm or 0)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
2021-05-06 11:50:44 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.bathroom_heater fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 316, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 524, in async_device_update
    raise exc
  File "/config/custom_components/xiaomi_miot/climate.py", line 173, in async_update
    await super().async_update()
  File "/config/custom_components/xiaomi_miot/__init__.py", line 792, in async_update
    self._update_sub_entities(
  File "/config/custom_components/xiaomi_miot/__init__.py", line 988, in _update_sub_entities
    self._subs[fnm].update()
  File "/config/custom_components/xiaomi_miot/switch.py", line 138, in update
    super().update()
  File "/config/custom_components/xiaomi_miot/__init__.py", line 1188, in update
    super().update()
  File "/config/custom_components/xiaomi_miot/__init__.py", line 1139, in update
    attrs = self._parent.device_state_attributes or {}
  File "/config/custom_components/xiaomi_miot/__init__.py", line 497, in device_state_attributes
    ext = self.state_attributes or {}
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 266, in state_attributes
    data[ATTR_PRESET_MODE] = self.preset_mode
  File "/config/custom_components/xiaomi_miot/climate.py", line 386, in preset_mode
    acm = -1 if acm is None else int(acm or 0)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
@al-one
Copy link
Owner

al-one commented May 11, 2021

This component adapts the HA function according to the miot property name. The HVAC and preset mode of the climate entity corresponding to the mode will not change because of a certain model of device. I don't think the miot-spec of this model is very standard.
For errors, please provide entity state attrs:

🔨 Developer tools > ℹ️ State > 🔍 Filter Entity

@blakadder
Copy link
Contributor Author

blakadder commented May 11, 2021

you're correct, its violating miot spec wherever it can.

hvac_modes: auto, off
min_temp: 16
max_temp: 25
target_temp_step: 1
fan_modes: High, Low
preset_modes: Fan not swing, Fan swing, off
current_temperature: 21.5
fan_mode: High
preset_mode: off
model: zhimi.heater.na1
lan_ip: 10.1.1.226
mac_address: 50:EC:50:93:78:79
firmware_version: 2.1.8
hardware_version: esp32
entity_class: MiotClimateEntity
miot_type: urn:miot-spec-v2:device:heater:0000A01A:zhimi-na1:2
return_to_middle: false
physical_controls_locked: false
indicator_light.brightness: 0
countdown.countdown_time: 0
alarm: false
heater.fault: 0
heater.on: false
heater.heat_level: 1
heater.mode: 0
state_updater: lan
sub_entities: physical_controls_locked-7.physical_controls_locked-1
friendly_name: Bathroom Heater
supported_features: 24
bind_sensor: sensor.bathroom_temperature_sensor_temperature
target_temperature: 23

@al-one
Copy link
Owner

al-one commented May 12, 2021

Please upgrade to latest commit of master branch.

@blakadder
Copy link
Contributor Author

blakadder commented May 12, 2021

sorry i previously pasted the heater entity supported attributes from the wrong entity. i edited the previous post with the correct information

al-one added a commit that referenced this issue May 14, 2021
@al-one al-one closed this as completed May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants