We control the Electrolux convector and thermostat from Home Assistant. Part 2

Part 1





Transfer of acquired knowledge to HA

It's time to apply this Python experience and integrate it into Home Assistant.





Since I had no experience in writing components for HA, I had to spend time learning how to write my own components for integration.





The first step was to implement an http client for authorization. Then it went about writing a tcp client. And at some point, a thought flashed through my mind: what if, in the first versions of the application, communication with the server / devices was not over TCP, but through REST.





Curiosity arose in me again, and I started searching and studying old versions of the application. And, lo and behold, success! I found exactly what I was looking for)





After studying the application, I found out what other handles there are for requests, besides authorization. This was what I needed: requesting the state of the devices and submitting the change.





Thus, there is no need to write a tcp client and you can focus on working with http requests.





The first step was to find out what the data returned by the server meant.





{'result': {'device': [{'state': '0', 'child_lock': '0', 'sensor_fault': '0', 'window_open': '0', 'mute': '0', 'window_opened': '0', 'calendar_on': '0', 'brightness': '1', 'led_off_auto': '0', 'temp_comfort': '10', 'delta_eco': '4', 'temp_antifrost': '7', 'mode': '1', 'mode_temp_1': '0', 'mode_temp_2': '0', 'mode_temp_3': '0', 'hours': '12', 'minutes': '0', 'timer': '0', 'current_temp': '9', 'heat_mode': '1', 'power': '1', 'code': '0', 'lcd_on': '1', 'time_seconds': '29', 'time_minutes': '53', 'time_hour': '21', 'time_day': '1', 'time_month': '4', 'time_year': '21', 'time_weekday': '4', 'preset_monday': '0', 'preset_tuesday': '0', 'preset_wednesday': '0', 'preset_thursday': '0', 'preset_friday': '0', 'preset_saturday': '0', 'preset_sunday': '0', 'preset_day_1': '0', 'preset_day_2': '0', 'preset_day_3': '0', 'preset_day_4': '0', 'preset_day_5': '0', 'preset_day_6': '0', 'preset_day_7': '0', 'preset_day_8': '2', 'preset_day_9': '2', 'preset_day_10': '2', 'preset_day_11': '2', 'preset_day_12': '2', 'preset_day_13': '2', 'preset_day_14': '2', 'preset_day_15': '2', 'preset_day_16': '2', 'preset_day_17': '2', 'preset_day_18': '2', 'preset_day_19': '2', 'preset_day_20': '2', 'preset_day_21': '2', 'preset_day_22': '2', 'preset_day_23': '2', 'preset_day_24': '0', 'tempid': '188577', 'uid': '188577', 'mac': 'set', 'room': '...', 'sort': '0', 'type': 'convector24', 'curr_slot': '0', 'active_slot': '0', 'slop': '0', 'curr_scene': '0', 'curr_scene_id': '0', 'wait_slot': '0', 'curr_slot_dropped': '0', 'curr_scene_dropped': '0', 'online': '1', 'lock': '0'}], 'invalid': [], 'waiting': [], 'invalid_device': [], 'waiting_device': []}, 'error_code': '0', 'error_message': ''}
      
      



examine the models in the application and figure out what to pass in order to change the parameter.





Thus, after some time, the first MVP version of the component appeared, which only worked for reading the current state of the convector.





, , , Electrolux/Balu . , " ".





3 ))) .





HA





HA, , HA





, .





In addition to the described way of communicating with the device through the substitution of the application, it is possible to go by communicating with the device directly, and ideally by creating sticks for working through zigbee and integration via MQTT. And for this, people with experience and knowledge are very needed.





Link to the repository and telegram








All Articles