Wifi thermostat (Beok, Floureon, Beca Energy) component

Hello,

I have started programming a custom component for the wifi thermostats above (heating only).

I am struggling to get the component to work (the standalone python code works although it could probably be improved!).

In a nutshell, I add the component in custom_components/climate/ and add the following in configuration.yaml

  • climate:
    platform: wifithermostat
    api_key: product_id_key_goes_here

I do not see any error messages or any debug messages in the log. Home Assistant does not seem to load the component and blocks the loading of all the other climate components (e.g. Nest), which makes me think there is something broken in the code :-/

Any help would be appreciated, this is my first component!

2 Likes

Right, after a bit of tweaking and tinkering, the component now works!
Latest version is at the GitHub location.

1 Like

awesome, does home assistant find the device automatically?
why is this ip address hardcoded in your code? “self.HOST = ‘59.110.30.249’” or do you need to change this in the code to the actual ip address of the thermostat in a network?

Hello,

The module communicates with the bestbeca.cn (ip: 59.110.30.249) where your thermostat is registered i.e. it does not communicate with the thermostat directly.

You need to register the thermostat first using the official app.

Once the module is in custom_components/climate/ just update your configuration.yaml to include:

climate:

  • platform: wifithermostat
    name: name_goes_here
    api_key: xxxxx [<— this is the product id you will find on the label on the thermostat]

Finally, please make sure you use the latest code from github!

Hi

thanks for the component. I wanted to test it but im not sure from where should I get api_key. I don’t see any numbers on the device.

Hi, not sure I can be of help, but this is what mine looked like (the ‘api_key’ is under the blackened area):

I’ve got BEOK and looks very similar, its missing that ID sticker. I guess I need to extract it somehow. I can try to take a look at wifi communication to find it. Now Im wondering, if authentication is based only on ID, that means bruteforcing ID ( how long is it and what format ? ) we could control someones thermostat ?

i have Floureon and no sticker :confused:

Yes, using a TCP sniffer, it is quite easy to snif the encrypted ID and reverse it.

Also agree with you on your second point, not the most secure…

Can you post format of that key ? I’m not sure what to look for, how long it is and is it only digits / hex or … ? I’ve dumped data from app and deserialized it. I got field called key with some md5 data and field called password with 6 digits but doesn’t seem to work when I test it with your component.

File “/config/custom_components/climate/wifithermostat.py”, line 196, in current_temperature
self._device.read_status()
File “/config/custom_components/climate/wifithermostat.py”, line 128, in read_status
data = bytearray.fromhex(hex(self.id_effect)[2:])
ValueError: non-hexadecimal number found in fromhex() arg at position 9

Hi, for me it is a 5 digit integer i.e. 00000 - I understand that’s the common format.

I also got one yesterday, and don’t have a sticker with ID on it :frowning: perhaps it is easy for you to sniff the encrypted id and reverse it, for me it isn’t lol, I’m using currently this method to integrate it in hass: https://community.openhab.org/t/electronic-heating-thermostat-reverse-engineering-beok-floureon-decdeal/39251/6
because without the ID, your method is not working unfortunately, I would rather use your method.
since the method on the openhab forum is also written in python, can’t the method without needing the ID not be integrated into your code, they are both written in python :stuck_out_tongue:

Hi, I did see this as well but the python involved there is beyond my capabilities I’m afraid…
To sniff the packets, I am using the “Packet Capture” app.

Once your thermostat is installed and configured with your app, you can use “Packet Capture” to see the traffic from the app.

You should see one of the packets being repeated often, which is your encrypted key in hex. You can then use the windows calculator to convert into decimal and the formula in the python code to reverse your product id.

Sounds simple :wink:

this sounds like real nasa science :slight_smile: i think i have packet, but how can i get id from there? “windows calculator” - what is this? sorry for stupid questions…

Right, if you have the packet in hexadecimal, you can google “hexadecimal to decimal” and you will find a free calculator to convert your packet into decimal.

Next, use this formula:
(encrypted ID - 65535) / 65535 - 1 = Product ID

I’ve made a platforme for this thermostat: https://github.com/home-assistant/home-assistant/pull/15363
The PR is still pending, but it work for me :slight_smile:

This platform do not require any ID, and is not based on the thermostat internet connexion (works localy).

Hope you’ll like it :wink:

1 Like

Exciting!!! Much better than my version as I like the non-dependence on the remote servers!

I saw you have an issue with Google assistant, which I managed to solve with mine (see here: Custom components integration with Google Assistant). If I manage to make it work with your code, I’ll send a commit.

sorry, but how can i use this?

I gave this a spin last night and connections to the thermostat timed out… not too sure what the problem is… I do however wonder whether the model I have is different and the API doc is wrong. That would also explain why @typeonegative cannot get my module to work.

@Emmanuel: Have you tried to use the broadlink.discover() function, using the broadlink API ? (not in HA, on a python terminal) ? I think I’ll update my code using this methode, but I’m running out of time this summer :wink:
And I fixed the google assistant issue yesterday !

@typeonegative: You have to create a custom_components/climate folder, on the HA config folder, and put the broadlink thermostat code on it, then add this to your configuration file:
climate:
- platform: broadlink
name: Thermostat
mac: “xx:xx:xx:xx:xx”
host: “xxx.xxx.xxx.xxx”
Finaly restart your HA instance, and you’ll be done :wink: