laetificat / haanna

Plugwise Anna API to use in conjunction with Home Assistant.
MIT License
5 stars 5 forks source link

Handle preset finding in XML better #14

Closed CoMPaTech closed 4 years ago

CoMPaTech commented 5 years ago

Modify (and test!) if searching for "a rule that has a template_id tag containing zone_setpoint_and_state_based_on_preset and has active set to true" instead of what is currently implemented in haanna.py (lines 62/63):

            rule_id = self.get_rule_id_by_name(root,
                                               'Thermostat presets')

As reported in https://github.com/home-assistant/home-assistant/issues/26520

bouwew commented 4 years ago

Can you please capture one last XML?

http://[your smile ip]/core/direct_objects

Another user has reported a similar issue and he found there's another XML-path where the actual indicator I'm looking for, is hidden. Hopefully the XML-data from your system can confirm this.

fwestenberg commented 4 years ago

Here it is: https://pastebin.com/6DaEQz9N

bouwew commented 4 years ago

Thanks! Was this capture taken with the heating in on/active state?

fwestenberg commented 4 years ago

The setpoint was 18 degrees while the actual temperature was about 19. So I say inactive. Even when I raise the setpoint:

IMG_20200109_163017 IMG_20200109_163036

fwestenberg commented 4 years ago

Here's a paste with thermostat active:

https://pastebin.com/dG1pVLWL

bouwew commented 4 years ago

Thanks. But no avail, the boiler_state still shows off. Strange, scratching my head...

fwestenberg commented 4 years ago

Stop scratching. It's in the direct_objects:

https://pastebin.com/6xzpXj79

bouwew commented 4 years ago

Yes, that is what I was expecting to see. Thanks! On the other hand, a bit strange too. I was expecting the key central_heating_state to be there too. The Pluswise Smile software works in mysterious ways... Anyway with this key I should be able to make it work.

bouwew commented 4 years ago

@fwestenberg Please try my latest code at https://github.com/bouwew/anna-ha Be sure to include the manifest.json file as this points to my updated haanna-version 0.14.0. This version contains most of your fixes as well.

Also, I had to reintroduce some old haanna-code that I had removed before. Without this code it is not possible to reactivate a previously used weekschedule on the latest Anna. This might reintroduce a bug for the legacy Anna. Let me know if there is an error in the log related to the "lambda" function.

fwestenberg commented 4 years ago

Thanks for the update, I'm testing it now. I removed the @staticmethod headers because I did not see any advantage in the statics here. It's probably a leftover of the code before, when the whole Anna component was sort of static and incompatible with multiple thermostats. I think it's not wrong to remove the statics, but also not wrong to keep it. For as far as I can see the component is working as it should. I tested both thermostats:

bouwew commented 4 years ago

Thanks for reporting back! During the coming days I will push all the recent improvements into the HA next branch.

fwestenberg commented 4 years ago

@bouwew shouldn't this have been fixed? Seems like I was still on the plugwise_dev integration, but after changing to the original plugwise integration this shows up:

plugwise: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/plugwise/climate.py", line 276, in update self._domain_objects File "/usr/local/lib/python3.7/site-packages/haanna/haanna.py", line 164, in get_last_active_schema_name rule_id = self.get_rule_id_by_template_tag(root, locator) File "/usr/local/lib/python3.7/site-packages/haanna/haanna.py", line 187, in get_rule_id_by_template_tag if rule.find("template").attrib["tag"] == rule_name: KeyError: 'tag'

bouwew commented 4 years ago

@fwestenberg Can you please change in the plugwise manifest.json file the line:"requirements": [...], the contents between [ and ] to:

"https://github.com/bouwew/haanna-1/archive/master.zip#haanna==0.14.2"

Then save the file and restart HA. Let me know the result.

Update: this fixed a similar issue for two other legacy Anna users.

WilbertVerhoeff commented 4 years ago

@bouwew I don't know if i'm allowed to command on this. So please kindly let me know.

I'm a legacy Anna user also. The change in the manifest.json works for me. However the illuminance is not in the attributes anymore. I don't know if the boiler state should be in it or the hvac -action should be update when de boiler is heating or not.

please let me know if i can help.

bouwew commented 4 years ago

@WilbertVerhoeff

Sure, feedback is always welcome :) Illuminance is not there because HA official did not allow it as an attribute. I have to add it as a sensor, which will probably be done sometime in the not too near future. I added boiler_state because for some installations the hvac-action was always idle, heating was not shown. Adding this made these systems show the heating status correctly.

CoMPaTech commented 4 years ago

I'm sort of tinkering with sensors (again), but it takes some time to get it right :(

bouwew commented 4 years ago

@WilbertVerhoeff If you really want the illumination-value, you would need to install the Plugwise component as a custom_component, and I could tell you which lines to add to the file climate.py to get the illumination-value back.

WilbertVerhoeff commented 4 years ago

@bouwew I have the custom component running with the haanna 14.2 (library?). If you want to, that would be really nice!

I want to thank you anyway for all the work you put in this integration. The Plugwise integration is THE reason i started with HomeAssistant.

bouwew commented 4 years ago

@WilbertVerhoeff Ok, no problem. The basis of the custom_component must be from the laetificat/anna-ha repository. Then, you need to add the following lines in climate.py:

Under the def __init__(self, api, name, min_temp, max_temp): part this line:

self._illuminance = None

Under def device_state_attributes(self): these 2 lines:

         if self._illuminance:
            attributes["illuminance"] = self._illuminance

And finally under def update(self): add this line:

self._illuminance = self._api.get_illuminance(self._domain_objects)

The placement of these lines doesn't really matter, as long as they are placed under the correct header.

For editing the file, I would suggest the Visual Studio Code add-on.

bouwew commented 4 years ago

@WilbertVerhoeff zou jij ons kunnen helpen? We hebben xml-data van de legacy anna nodig om te kunnen komen tot een Home Assistant component die werkt voor alle Plugwise apparaten (Anna, Adam, Smile P1, etc.) We zijn al een behoorlijk eind op weg maar deze data missen we nog.

WilbertVerhoeff commented 4 years ago

Yes, I want to help! How do you want the data? Can I copy paste it some where? Or can I open a port so you can watch when you want?

bouwew commented 4 years ago

Great! Please go here: https://github.com/plugwise/Plugwise-Smile/tree/master/tests And scroll a bit down for the exact URLs. You will get the best result by browsing to the page, then right-click on the text and choosing Save as... Then save them all as xml-file.

Also, please browse to http://{ip_of_your_smile}//system/status/xml and save the data there as well if there is any data.

Please email all the files to bouwe "@" westerdijk "." info (spaties en " weghalen).

Alvast bedankt!

bouwew commented 4 years ago

@fwestenberg We are working on a common platform for all Plugwise devices. There will be support for the Plugwise Anna's, Smile P1's and the Adam, and Plugs via the Adam. We have tested with the Adam, Plugs and the Anna with firmware 3.1.11. Now we are looking for testers that have a legacy Anna. Are you willing to help?

fwestenberg commented 4 years ago

Sure! Just let me know what to do!

bouwew commented 4 years ago

Very good, thanks!. First, disable the present component, best to do this by removing the plugwise-lines in configuration.yaml and restarting HA. Next, go here: https://github.com/plugwise/plugwise-beta/ and read the information shown in README.md. Any questions regarding this, let me know here.

After having installed the new component and having configured it, please check the result: are all the various entities there? If anything went wrong, check the Log and send us the error-info. Please provide as detailed feedback as possible.

bouwew commented 4 years ago

Or, the feedback can be given here: https://community.home-assistant.io/t/advice-how-to-load-sensor-info-from-plugwise-anna-thermostat-web-interface-xml/87801

CoMPaTech commented 4 years ago

@fwestenberg @WilbertVerhoeff we've just released 0.2.0 of our custom_component (with an upstream HA-PR in progress). As per the release of HA-core 0.109 this wednesday (or if you already run HA-core beta 109) you can start using plugwise-beta.

Closing this issue. If you have any further comments or issues feel free to update

The (community post)[https://community.home-assistant.io/t/plugwise-smile-custom-component-beta/183560/3?u=compatech] The (module)[https://github.com/plugwise/Plugwise-Smile] replacing this repository The (custom_component)[https://github.com/plugwise/plugwise-beta]