rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.75k stars 561 forks source link

Add zhimi.heater.za2 and zhimi.heater.zb1 support #863

Closed 2esq closed 2 years ago

2esq commented 4 years ago

Hi I was wondering if this smart heater was implemented or not. When I run the command miiocli device --ip <ip address> --token <token> info (with my IP and token) I get this info:

Model: zhimi.heater.za2 Hardware version: esp32 Firmware version: 2.1.4

but I can't seem to send any command to the heater. I understand this device uses MIoT and it's still a in it's early days of development but is there a way to expose the heater to home assistant?

Thanks

rytilahti commented 4 years ago

The support for these devices is added in #625, you should be able to use miiocli heater to control the device. If that doesn't work, feel free to reopen this!

We don't track homeassistant implementations in this repository, the proper forum for homeassistant integration is homeassistant's community forums. Or maybe @syssi has a custom integration available (looks like the API is quite similar to some other devices :-)?

2esq commented 4 years ago

When I do miiocli heater --ip xx.x.x.xx --token 3b46e0dde8dxxxxxxxxxx45ee81b2c39 on I get: Powering on Error: {'code': -5001, 'message': 'command error'} Same thing for any other command.

What could be causing this?

rytilahti commented 4 years ago

Okay, that's clearly a bug so let's reopen this. That message is coming from the device, maybe this device uses different commands than the one in the implementation. Is any other command working?

Ping @bazuchan - do you have an idea?

bazuchan commented 4 years ago

Maybe get_prop vs get_properties ?

syssi commented 4 years ago

The supported devices

MODEL_HEATER_ZA1 = "zhimi.heater.za1"
MODEL_HEATER_MA1 = "zhimi.elecheater.ma1"

are miIO devices. The zhimi.heater.za2 is a mioT device. In short: The ZA2 isn't supported right now.

syssi commented 4 years ago
# miot specs

Service: siid 1: (Device Information): 4 props, 0 actions
  * Property piid: 4 (Current Firmware Version): (string, unit: None) (acc: ['read'], value-list: [], value-range: None)
  * Property piid: 1 (Device Manufacturer): (string, unit: None) (acc: ['read'], value-list: [], value-range: None)
  * Property piid: 2 (Device Model): (string, unit: None) (acc: ['read'], value-list: [], value-range: None)
  * Property piid: 3 (Device Serial Number): (string, unit: None) (acc: ['read'], value-list: [], value-range: None)
Service: siid 2: (Heater): 3 props, 0 actions
  * Property piid: 1 (Device Fault): (uint32, unit: None) (acc: ['read', 'notify'], value-list: [], value-range: [0, 4294967295, 1])
  * Property piid: 2 (Switch Status): (bool, unit: None) (acc: ['read', 'write', 'notify'], value-list: [], value-range: None)
  * Property piid: 6 (Target Temperature): (float, unit: celsius) (acc: ['read', 'write', 'notify'], value-list: [], value-range: [16, 28, 1])
Service: siid 3: (Alarm): 1 props, 0 actions
  * Property piid: 1 (Alarm): (bool, unit: None) (acc: ['read', 'write', 'notify'], value-list: [], value-range: None)
Service: siid 4: (Countdown): 1 props, 0 actions
  * Property piid: 1 (定时关机时间): (uint32, unit: hours) (acc: ['read', 'write', 'notify'], value-list: [], value-range: [0, 8, 1])
Service: siid 5: (Environment): 2 props, 0 actions
  * Property piid: 7 (Relative Humidity): (uint8, unit: percentage) (acc: ['read', 'notify'], value-list: [], value-range: [0, 100, 1])
  * Property piid: 8 (Temperature): (float, unit: celsius) (acc: ['read', 'notify'], value-list: [], value-range: [-30, 100, 0.1])
Service: siid 6: (Indicator Light): 1 props, 0 actions
  * Property piid: 1 (亮度): (uint8, unit: percentage) (acc: ['read', 'write', 'notify'], value-list: [], value-range: [0, 2, 1])
Service: siid 7: (Physical Control Locked): 1 props, 0 actions
  * Property piid: 1 (童锁功能): (bool, unit: None) (acc: ['read', 'write', 'notify'], value-list: [], value-range: None)
Service: siid 8: (private-service): 2 props, 0 actions
  * Property piid: 1 (按键点击): (int32, unit: None) (acc: ['notify'], value-list: [], value-range: [0, 6, 1])
  * Property piid: 7 (): (uint32, unit: seconds) (acc: ['read', 'notify'], value-list: [], value-range: [0, 4294967295, 1])
  * Event eiid 1 (high temperature exception): (args: [])
  * Event eiid 2 (温湿度传感器异常): (args: [])
  * Event eiid 3 (status report): (args: [])
  * Event eiid 4 (childlock trigger): (args: [])
  * Event eiid 5 (E2PROM 异常): (args: [])
  * Event eiid 6 (): (args: [])
2esq commented 4 years ago

syssi, is there any way to control the heater, even with raw commands? I reckon in homebridge there is an integration already working. https://github.com/github9984/homebridge-smartmi-heater#readme

rezmus commented 4 years ago

@maskiopt use above specs and send raw commands like this

{"method":"set_properties","params":[{"did":"X","siid":2,"piid":2,"value":true}],"id":123} # turn on {"method":"get_properties","params":[{"did":"X","siid":2,"piid":6}],"id":123} # get target temperature

"did" may not be necessary (depends on device).

devpitx commented 3 years ago

Model: zhimi.heater.zb1

dmytro@dell-7510:/mnt/d/Desktop$ miiocli heater --ip 192.168.0.XX --token ****** off
Powering off
Error: {'code': -5001, 'message': 'command error'}
devpitx commented 3 years ago

how can I help you to add it to the supported list?

rezmus commented 3 years ago

it's miot device, it won't work via miio class.

al-one commented 3 years ago

https://github.com/al-one/hass-xiaomi-miot/issues/12#issuecomment-770557206

al-one/hass-xiaomi-miot supported zhimi.heater.ma3, Maybe you can try this component for HA.

xztxy commented 3 years ago

zhimi.heater.za2 image image

al-one/hass-xiaomi-miot#12 (comment)

al-one/hass-xiaomi-miot supported zhimi.heater.ma3, Maybe you can try this component for HA.

PRO-2684 commented 2 years ago

From this helpful link, I created heater_miot_za2.py based on heater_miot.py, which added zhimi.heater.za2 support. PR here. #1301

rytilahti commented 2 years ago

This can be now closed thanks to @PRO-2684 - please open a separate issue if the miiocli heatermiot is not working for other models.