sergio_pt
(Sergio_PT)
December 6, 2020, 8:33pm
1
I bought this new Xiaomi Heater and there was no component to integrate it into Home Assistant. So…
Based on others work, I kind of modified other components to make them work with this heater and I’m pleased to share it with you all
Please note I’m not a developer and this was my first time around python.
Repo:
8 Likes
Thank you!
it’s working for heater.mc2
1 Like
royen99
(Nico)
December 7, 2020, 4:25pm
3
Trying this with a zhimi.heater.zb1, but errors in logs:
2020-12-07 17:31:02 WARNING (SyncWorker_5) [custom_components.miheater.climate] zhimi.heater.zb1 2.0.8 esp32 detected
.....
2020-12-07 17:31:04 ERROR (MainThread) [homeassistant.components.climate] Error while setting up miheater platform for climate
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
await asyncio.shield(task)
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/miheater/climate.py", line 68, in setup_platform
miHeater = MiHeater(device, name, unique_id, hass)
File "/config/custom_components/miheater/climate.py", line 97, in __init__
self.getAttrData()
File "/config/custom_components/miheater/climate.py", line 151, in getAttrData
data['target_temperature'] = target_temperature[0]["value"]
KeyError: 'value'
.......
Exact model:
NAME: Smartmi Smart Convector Heater 1S
ID: 358650775
MODEL: zhimi.heater.zb1
Any idea’s ?
sergio_pt
(Sergio_PT)
December 7, 2020, 4:48pm
4
What integration are you using?
I dont have that heater, but I can take a look at the integration.
Good Work Sérgio, i´m glad to see the Portuguese guys sharing
knowledge to world, thank you for your effort.
1 Like
royen99
(Nico)
December 7, 2020, 5:14pm
6
The error from above is from your custom_component (https://github.com/ee02217/homeassistant-mi-heater ).
Also tried https://github.com/fineemb/Smartmi-smart-heater , but this gives a (somewhat) similar error.
Inside the HA config:
- platform: miheater
host: 192.168.1.141
token: !secret xiaomi_heater
name: heater1
sergio_pt
(Sergio_PT)
December 7, 2020, 5:19pm
7
Then that’s the problem
My component is for another heater: zhimi.heater.mc2.
They have different controls.
You may want to try this other repo but I cant guarantee it works. I could try to create an integration for that one, but I dont have that model.
https://github.com/gaussian8/homeassistant-mi-heater
sergio_pt
(Sergio_PT)
December 7, 2020, 6:40pm
8
royen99:
zb1
Hi @royen99 , I have updated my code to also support zhimi.heater.zb1.
Please note that this is not tested as I dont have that heater.
Plus: my code is a bit spaghetti at the moment
sergio_pt
(Sergio_PT)
December 7, 2020, 11:28pm
9
royen99:
358650775
I’m not sure the updates will work because there is a did parameter that I believe is specific to my model, but would appreciate if you can try it.
royen99
(Nico)
December 8, 2020, 8:04am
10
That indeed seems to do a lot more
It does get the proper properties (on/off and the temperature setting), but setting them not.
sergio_pt
(Sergio_PT)
December 8, 2020, 8:22am
11
Hi @royen99 ,
That is good news. I’ll try to fix it as well this afternoon.
It would be great if someone with more python knowledge could help as well, as I’m sure the code can be optimized.
Also, I found out that if connection to device is lost, it does not get it back. So I’ll need to see how to ensure it tries to connect the device again.
sergio_pt
(Sergio_PT)
December 8, 2020, 2:06pm
12
Hi @royen99 ,
I have updated the code. Please let me know if you can already set temperature and turn heater on and off
2 Likes
royen99
(Nico)
December 8, 2020, 2:42pm
13
Seems to fully work indeed.
Both on/off and changing temperature!
2 Likes
myrayearth
(Rayearth)
December 8, 2020, 10:50pm
14
Za2 is work too!
Thank you
1 Like
sergio_pt
(Sergio_PT)
December 8, 2020, 10:53pm
15
Thank you very much for the feedback!
In the next couple days I’ll try to make device detection better. Currently it’s querying the device everything, I’ll try to use is as config so that the integration becomes faster.
Would also love to make this hacs compatible and with better documentation. Hehehe
Hi,
I have Za2 and it is not working, have you done any changes to the integration?
myrayearth
(Rayearth)
December 10, 2020, 4:16pm
17
Sorry, I didn’t test this myself.
It is a test result shared by members of the Home Assistant community in Korea.
I’ve been informed by 2 people that it works without modification.(za2 model)
Thanks for the feedback.
Weird that I did not got it to work
geosoftgr
(George)
December 14, 2020, 4:46pm
19
Hi Sergio_pt
Thanks for this integration work like a charm, but I will like to know how can I add the card that you have as an example in your GitHub page in my home assistant overview page?
sergio_pt
(Sergio_PT)
December 14, 2020, 6:10pm
20
Hi George,
This is my card:
- type: 'custom:simple-thermostat'
name: false
control:
hvac:
another_mode: false
away: false
'off':
icon: 'mdi:power'
name: 'OFF'
'on':
icon: false
name: 'ON'
some_mode: false
entity: climate.zhimi_heater_mc2_5c_e5_0c_e0_1a_f7
sensors:
- entity: sensor.plug_heater_energy_today
name: Energy Today
- entity: sensor.plug_heater_energy_power
name: Power
- entity: sensor.electricity_cost_monthly
name: Cost
- attribute: min_temp
name: Min temp
step_size: 1
Please note that information related to power usage is coming from a smart plug…
I have now updated my card as below:
type: entities
title: Mi Heater
show_header_toggle: false
entities:
- type: 'custom:simple-thermostat'
name: false
control:
hvac:
another_mode: false
away: false
'off':
icon: 'mdi:power'
name: 'OFF'
'on':
icon: false
name: 'ON'
some_mode: false
entity: climate.zhimi_heater_mc2_5c_e5_0c_e0_1a_f7
sensors:
- entity: sensor.plug_heater_energy_today
name: Energy Today
- entity: sensor.plug_heater_energy_power
name: Power
- entity: sensor.electricity_cost_monthly
name: Cost
- attribute: min_temp
name: Min temp
step_size: 1
style: |
ha-card {
border-radius: 15px;
background-color: rgba(0,0,0,0);
box-shadow: 0px 0px 0px 0px rgba(0,0,0,0.0);
border: solid 1px rgba(25,25,25,1.0);
}
- type: 'custom:mini-graph-card'
hours_to_show: 24
points_per_hour: 12
animate: false
decimals: 1
height: 200
show:
icon: false
name: false
state: true
fill: true
labels: true
labels_secondary: false
extrema: false
lower_bound: 18
upper_bound: 25
line_width: 3
hour24: true
state_map:
- label: 'Off'
value: '0'
- label: 'On'
value: '1'
entities:
- entity: sensor.thermostat_temperature
name: Temperature
color: orange
show_fill: false
show_legend: true
show_points: true
smoothing: true
- entity: sensor.thermostat_setting
name: Thermostat
color: red
show_fill: false
show_line: true
show_points: true
smoothing: false
- entity: sensor.xiaomi_heater_switch
name: Switch
color: 'rgba(57,255,35,1)'
show_fill: true
show_line: false
show_legend: false
show_points: false
smoothing: false
style: |
ha-card {
border-radius: 15px;
background-color: rgba(0,0,0,0);
box-shadow: 0px 0px 0px 0px rgba(0,0,0,0.0);
border: solid 1px rgba(25,25,25,1.0);
}
5 Likes