nicole-ashley / homeassistant-goldair-climate

Home Assistant integration for Goldair WiFi heaters, dehumidifiers and fans
MIT License
19 stars 10 forks source link

GoldAir Wifi Fan not being detected as a fan #40

Open jwhite opened 3 years ago

jwhite commented 3 years ago

This is what I have in my logs....

2021-02-13 11:13:52 INFO (SyncWorker_0) [custom_components.goldair_climate.device] refreshed device state: {"devId": "03016700e0980606e6f6", "dps": {"1": true, "2": "1", "3": "1", "4": "off", "6": "0", "19": 24, "updated_at": 1613168032.1845233}} 2021-02-13 11:13:52 DEBUG (SyncWorker_0) [custom_components.goldair_climate.device] new cache state (including pending properties): {"1": true, "2": "1", "3": "1", "4": "off", "6": "0", "19": 24, "updated_at": 1613168032.1845233} 2021-02-13 11:13:52 DEBUG (MainThread) [custom_components.goldair_climate.device] Inferring device type from cached state: {'1': True, '2': '1', '3': '1', '4': 'off', '6': '0', '19': 24, 'updated_at': 1613168032.1845233} 2021-02-13 11:13:52 ERROR (MainThread) [homeassistant.components.climate] Error adding entities for domain climate with platform goldair_climate Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 315, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 506, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 531, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 296, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 322, in _async_write_ha_state attr.update(self.state_attributes or {}) File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 219, in state_attributes ATTR_CURRENT_TEMPERATURE: show_temp( File "/usr/src/homeassistant/homeassistant/helpers/temperature.py", line 23, in display_temp raise TypeError(f"Temperature is not a number: {temperature}") TypeError: Temperature is not a number: off

I will try to set the detection by hand and see what I get.

make-all commented 3 years ago

It's quite different from the schema of the fan that is supported. dps: "1": true, "2": "1", "3": "1", "4": "off", "6": "0", "19": "24"

current fan schema: dps: "1": hvac_mode[false=off, true=fan], "2": fan_mode[1-12], "3": preset_mode[normal|nature|sleep], "8":swing_mode[false=off, true=horizontal], "101":display[false=off ,true=on]

DPS 1 and 2 may match, but the others are all different, and the mismatch of 3 at least is likely to cause the code to throw exceptions and the device not to work at all if manually set to fan.

jwhite commented 3 years ago

No, I mean I was hacking the code to work with the new schema. I forked the repo - is anyone available to give me a quick overview of how to use the toolchain to quickly get my code up and running?

I have docker/build container/code/etc. installed already. I need a quick best practices walkthrough.

make-all commented 3 years ago

For development, I just use a VM environment with pytest for running the unit tests. If you look at .github/workflows/tests.yaml, you should get some idea of what is required. For actual runtime testing, I deploy to my raspberry pi actual HA installation (probably not the best practice, but it isn't a mission critical system).

I think the features of your fan are sufficiently different that you would be best creating a new device. Copy the fan directory to a new directory and start from there. You'll need to figure out what each DPS is for, by changing settings on the fan manually and observing the DPS changes. DPS 19 is in the right range to be a current_temperature reading, which isn't supported by the current fan, so look at one of the heater devices to see how that is handled. Once you've figured them all out, remove the things that aren't supported by your fan, and add in the additional features if you want to support them (things like timers probably aren't useful to support, as there is no easy way to use them from HA). Link the new device in to the top level device.py and climate.py by looking for where the fan is being used and do something similar for your new device (I suggest using the model in the name, like the newly added heaters).

nicole-ashley commented 3 years ago

Hi @jwhite, apologies for the delay. As it's been summer I've not been paying as much attention to this integration as I should.

Which model of fan do you have? Would you be willing to do some investigation to figure out the DPS schema? I can help you with instructions. If we can figure out the schema I'd be happy to add support to the integration.

jwhite commented 3 years ago

@nikrolls The fan is model GPTF390

You can see the fan here [fan]https://www.harveynorman.com.au/goldair-platinum-117cm-tower-fan-with-wifi.html(url)

I don't mind adding it either - as I already forked the repo to do some testing. I am not sure how to disambiguate it from the other devices however, as there is overlap on the schema. The fan is reporting 1,2,3,19 (on, ?, speed, temp).

Getting a key to communicate with it involved decompiling the goldair apk to remove the encryption on the packets and then doing a remote packet capture. So, I do have raw data as well.

Ideas on how to disambiguate?

I mostly got slowed down on setting up a workable toolchain that pushes the code to my instance. What do you use? File copy to network share?

Cheers! -Jeremy

make-all commented 3 years ago

Is the fan only reporting those 4 dps and no others?

The URL has disappeared, but Goldair has a matching GPTF390 (exclusive to Harvey Norman) on their website. According to the manual, there should be control of power, presets, oscillation, speed, and a timer. And it contains a digital thermometer, so presumably the temperature reading is coming back. So I'd expect at least 6 dps.

The detection by checking small numbers of dps gets harder the more devices are added. Maybe check the type as well if you can't find a combination that doesn't exist in other devices.

jwhite commented 3 years ago

dps: "1": true, "2": "1", "3": "1", "4": "off", "6": "0", "19": "24"

So 6 dps.

@make-all

make-all commented 3 years ago

OK, sorry, I see you had all that info back at the start. So: 1 = switch (hvac_mode) 2 = ? 3 = speed (fan_mode) [1=low, 2=mid, 3=high?] 4 = ? 6 = ? 19 = current_temperature

I guess the information needed is which of 2,4 and 6 is preset mode, and which is oscillation, and what values those can take. And is it correct that this is a three speed fan, so the range for dps 3 is 1-3?

make-all commented 3 years ago

This looks like it could be the same DPS layout as the Kmart Anko fan with an additional temperature sensor. In that case, I guess DPS 2 would be the presets with '1', '2', '3', '4' for 'normal', 'nature', 'sleep', 'child' (maybe not in that order), DPS 4 would be the oscillation switch, with either 'off' and 'auto' like the Anko fan, or 'off' and 'on', and 6 will be the timer.