sarahhenkens / home-assistant-iocare

27 stars 15 forks source link

Add set_timer service, timer and timer_remaining attributes, update version to use Semantic Versioning #18

Closed RobertD502 closed 2 years ago

RobertD502 commented 3 years ago

Any chance we could get these changes merged and a new release created so the update is available to others through HACS?

Jamonek commented 3 years ago

Bump

robert-alfaro commented 2 years ago

@sarahhenkens bump

j9brown commented 2 years ago

Hey Robert, I wasn’t able to get your fork running since it seems to depend on version 0.2.0 of python-iocare that isn’t publically available as far as I can tell. It seems you might have made a fork of it but the URL listed in manifest.json yields a 404.

RobertD502 commented 2 years ago

Hey Robert, I wasn’t able to get your fork running since it seems to depend on version 0.2.0 of python-iocare that isn’t publically available as far as I can tell. It seems you might have made a fork of it but the URL listed in manifest.json yields a 404.

@j9brown Did you delete your current iocare folder from "custom_components" and then added my forked repo URL in HACS/installed the integration? The manifest in my repo points to a fork I made of the required library (this is the only way of using the changes I made to the library without getting the original creator to push the updated code to PyPi). Once you install the integration through HACS using my repo / restart Home Assistant, Home Assistant will pull in my fork of the library that is used.

j9brown commented 2 years ago

Hmm. I did not find an iocare folder in custom_components and restarting HASS had no effect. I do see the following message in the log, but no indication as to whether an error occured:

2022-02-20 23:59:17 INFO (SyncWorker_5) [homeassistant.util.package] Attempting install of git+https://github.com/RobertD502/python-iocare@master#python-iocare==0.2.0

Curiously, I no longer receive a 404 when opening the https://github.com/RobertD502/python-iocare repository in a web browser. Maybe I copied the link incorrectly before?

Still not working, in any case.

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 614, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 782, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 539, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 572, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in _stringify_state if (state := self.state) is None: File "/config/custom_components/coway/sensor.py", line 74, in state return round(float(self._device.quality["air_quality_index"]), 1) AttributeError: 'Purifier' object has no attribute 'quality'

RobertD502 commented 2 years ago

Sorry, I meant delete the Coway folder that was installed from this repo prior to adding my repo into HACS and installing the integration.

Edit:

So,

1: delete the coway folder from custom_components either manually or by going into HACS and uninstalling the integration 2: restart home assistant 3: add my forked repo to HACS (repo to the fork I made of this integration, not the python-iocare library) 4: install the integration via hacs 5: restart Home Assistant

j9brown commented 2 years ago

I've already uninstalled / updated the repo / reinstalled / restarted and I can attest that the custom_components/coway folder contains the latest version from your repository. It could be the problem is elsewhere.

Looking at the code, it seems like some fields of the Purifier object might not be initialized if there's an error parsing them from the API response. That would result in the AttributeError I observe at startup.

(I had assumed there was some kind of dependency mismatch due to the nature of the AttributeError and because I was unable to find the python-iocare library mentioned in the manifest for whatever reason.)

j9brown commented 2 years ago

If it helps, I also observe the following error in the log which suggests that the attempt to refresh the control status fails pretty early. Maybe the server returned an error.

AttributeError: 'Purifier' object has no attribute 'is_on'

RobertD502 commented 2 years ago

Which purifier do you have? The 300/400 or the new one they released not too long ago?

j9brown commented 2 years ago

I have a model 400S.

Ok, it turns out that the purifier dropped off the wifi. After reconnecting the purifier to wifi, the integration seems to work fine.

Most likely the server is returning a response that the integration doesn't know how to parse when the purifier is offline. If this occurs on startup of home assistant, then some fields of the Purifier object will not be populated and the integration will throw exceptions further downstream. So I think it would be good to populate those fields in some way that can tolerate the purifier being offline without crashing or reporting stale data and to inform the user in some manner such as by marking the device as unavailable.

Thanks for your help!

RobertD502 commented 2 years ago

Correct, those fields are null when the purifier is offline. I'll have to see if there is another key showing if a purifier is connected to their servers and set the state in HA based off of that - just haven't had any time to further work on this integration as I've been tied up in other projects.

j9brown commented 2 years ago

No worries, I'm in the same boat. :)

RobertD502 commented 2 years ago

Closing as I am now planning on maintaining any changes on my fork