Xiaomi Smart Space Heater S(zhimi.heater.mc2) plus zhimi.heater.zb1 (not tested) and zhimi.heater.za2 (not te

That is what I did. removed the install I had on hacs and made sure there was no other directory on the custom_components. Created the miheater folder and downloaded your files to that directory.

At the moment yours is the only component in the custom_components folder, and I get that same log message.

That is weird since I am not able to reproduce the error.
Can you confirm your version?

Also, I recommend to install my version using HACS by adding my repository.
And clean the cache please.

Removed everything, cleared cache, restarted browser, added by your HACS reporitory, restarted the server and:
´´´
Logger: homeassistant.components.climate
Source: custom_components/miheater/climate.py:67
Integration: Climate (documentation, issues)
First occurred: 9:07:56 PM (1 occurrences)
Last logged: 9:07:56 PM

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 67, in setup_platform device = Device(host, token)
File “/usr/local/lib/python3.8/site-packages/miio/device.py”, line 119, in init self._protocol = MiIOProtocol(ip, token, start_id, debug, lazy_discover)
File “/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py”, line 42, in init self.token = bytes.fromhex(token) ValueError: non-hexadecimal number found in fromhex() arg at position 33
´´´

This is really wierd… running your version 1.2 with Home Assistant 2020.12.1

I can see now that is seems to be complaining about your token.
Are you sure that is correct?
Can you share your configuration but changing some characters of token to keep anonymity?

Oh… I just noticed that I have an za2, and not a zb1…
It is just like the picture from the zb1 so I didn’t even reflect… I went to extract the tokens again to make sure it was correct, and noticed the “MODEL: zhimi.heater.za2”, don’t know if it could be the problem.
I have updated the “model” in the code, but it still gives me the same error.
My code is this (with changed token)

climate:
  - platform: miheater
    host: 192.168.50.166
    token: ff01b41b24cb953bccd633653b952cc0A
    name: xiaomi_heater
    model: zhimi.heater.za2

This is on server “DE”, if it helps in any way

The error is really strange. Is there anyway you can check that you have the correct token? It should be an hexadecimal string, and the error is saying it’s not.
Please confirm it only contains numbers and lowercase “a” to “f”.

Hi Sergio,
For some reason, this morning it started working. Maybe it still had something in the cache…
Either way, it works perfectly :smiley:
Thanks for all the help and patience :smiley:

1 Like

Hello @sergio_pt!

First of all, thanks a lot for your contribution, i have on of these heaters, and the integration is working so far!
Just some questions I got:

  1. How did you get those sensors for your card? sensor.thermostat_temperature, sensor.thermostat_setting & sensor.xiaomi_heater_switch? Are those template sensors? Can you share them?
  2. When I was configuring the integration, I first installed the repository into HACS, and restarted my HA instance before changing my config file, and HACS didn’t even boot up properly. After that, I completed the configuration, and after restarting, HACS was ok. Maybe this has something to do with a hang on the custom component?
  3. My climate entity shows this warning/error:
    This entity ("climate.zhimi_heater_mc2_64_90_c1_93_8f_02") does not have a unique ID, therefore its settings cannot be managed from the UI. See the [documentation](https://www.home-assistant.io/faq/unique_id) for more detail.
    Any idea? I can’t also change the entity id/name.

To finish up, I am not a very experienced Python developer, but I am professionally an SW developer, so if you need any help developing new features, fixing stuff or refactoring, let me know!
Cheers from Braga!

Hi Carlos,

Let me breakdown my answer and apologies for the delay, but I just got back to PC from the holidays :slight_smile:

Regarding the sensors for my card, I have used the below templates:

  - platform: template
    sensors:
      heater_switch:
        friendly_name: "Heater Switch"
        value_template: >-
          {% if is_state('switch.plug_heater', 'off') %}
            0
          {% elif is_state('switch.plug_heater', 'on') %}
            1
          {% endif %}
      xiaomi_heater_switch:
        friendly_name: "Xiaomi Heater Switch"
        value_template: >-
          {% if is_state('climate.zhimi_heater_mc2_5c_e5_0c_e0_1a_f7', 'heat') %}
            {{ state_attr('climate.zhimi_heater_mc2_5c_e5_0c_e0_1a_f7', 'current_temperature') }}
          {% elif is_state('climate.zhimi_heater_mc2_5c_e5_0c_e0_1a_f7', 'off') %}
            0
          {% endif %}

The second point you mention, is something that didn’t happen to me, there should be no issue in having an integration without a configuration, it would just mean that the instance does to instantiate it. But I really don’t know :frowning:

Regarding the third point, that warning happens because this integration is not using default Home Assistant integration configuration (it is still using yaml to initiate and get the token, versus configuring in “integrations”)

For the final point, this was my first python experience and I haven’t programmed in quite a few years now, so, if you want to check the code and fix it or add more functionalities, I would very much welcome it. :slight_smile: I believe the repository is public and you can make PRs.

Cheers from Lisbon!

1 Like

Hello Sergio!
No problem, don’t apologize for that :slight_smile:

Thanks for sharing, i tweaked it up a bit, but i get the point!

Blockquote
The second point you mention, is something that didn’t happen to me, there should be no issue in having an integration without a configuration, it would just mean that the instance does to instantiate it. But I really don’t know :frowning:

Yes, probably something related to HACS or smtg.

Blockquote
Regarding the third point, that warning happens because this integration is not using default Home Assistant integration configuration (it is still using yaml to initiate and get the token, versus configuring in “integrations”)

Ah ok, no problem then.

Blockquote
For the final point, this was my first python experience and I haven’t programmed in quite a few years now, so, if you want to check the code and fix it or add more functionalities, I would very much welcome it. :slight_smile: I believe the repository is public and you can make PRs.

Yes, the repo is public! Probably trying to put the configuration via UI, instead of YAML, would be a nice improvement. In the coming week, i’ll setup the development environment and try to play with it a bit.

Thanks a lot!

Hi!

I just discovered this heater “Xiaomi Smart Heater 1S” and I am considering buying a couple of them if they can integrate to Home Assistant (Which it seems they can thanks to your work - awesome, thanks!).

However I was wondering if it is possible to regulate the wattage on this heater? It seems like it is only possible to regulate the temperature? (Either with the integration or native app, or even the touch screen).

Let’s say I wanted to run it at just 1000W or something like that, is it possible?

Thanks.

1 Like

Hi!

It’s not possible to regulate the power. Not even from the Xiaomi app.
It is something it does internally based on it’s temperature sensor. I really wish we could do it, as I find its internal temperature sensor unreliable.

1 Like

Hey, thanks a lot for clarifying.
That is a shame, as most normal heaters usually have at least 2-3 power settings.
But that is what I feared while looking at the details and specifications.
2200W is basically a whole 10A circuit, so it would be nice to have some control over it.
I might have to reconsider, or maybe just buy 1 instead of 2 as I first planned.
Are you happy with it besides this?

I am really happy.
Yesterday was a really cold day here (Lisbon), so for the fist time I left it with the setting for 28C and it kept my livingroom above 23C (constant) which was really nice.
In the morning, I use an automation to heat the bedroom to 20C and it does the job very nicelly.
(this was my reason to buy it, it doesn’t dry the air as much as other heaters).

@sergio_pt, I would really like to thank you for the great work you did here.
I’m starting to play with Home Assistant and was looking for integrating my Xiaomi Smart Heater S, and luckily I found this thread!

Off-topic: earlier you mentioned that the

I was also looking to buy a smart plug (with power usage data) that I could easily integrate with HA. Could you please share which one you use since that is obviously confirmed to work fine?

1 Like

Hi!

Thank you for your words.
I have a few different plugs flashed with Tasmota.
The one I’m using with the heater is:
https://www.blitzwolf.com/3840W-EU-WIFI-Smart-Socket-p-244.html

Thanks for the reply, @sergio_pt.

3840 W (16 A) - that is exactly what I was looking for.
But apparently, I will need to add that “Tasmota flashing” to my learning stack (besides HA, etc…).
In my laziness, I was expecting to find some smart plug that I could “plug-an-play” to HA :wink:

I understand what you are saying. But it was really easy!
Just follow this guide:

No cables or soldering, just software :slight_smile:

1 Like

Hmmm, “just software” - you convinced me :wink:
Here I go buy me a plug.

Hehehehe
Believe me :slight_smile:
I’m not a developer. I just like technology and with these helpfull communities everything is doable. Hehehehe