Advice how to load sensor info from Plugwise Anna thermostat web interface XML

When I installed a heatpump/compressor I switched from a Nest thermostat to the Anna thermostat. I have not found any supported platform for Home Assistant to directly access and control this thermostat but I really wanted to :grin:

I started to fiddle with the webinterface and was able to connect and extract all the sensor information from the XML that the webinterface uses through a python script. It includes everything that I need:

  • Temperature of the room
  • Thermostat temperature setting
  • Outdoor temperature (below 4 C the heatpump is inefficient)
  • Boiler water temperature
  • Heating state on/off
  • Heatpump state on/off

From there I wanted to use the command_line platform to get the values from the script to Home Assistant.
This is what I created

  - platform: command_line
    name: Thermostaat
    json_attributes:
      - temperatuur
      - buiten_temperatuur
      - thermostaat
      - water_temperatuur
      - verwarming
      - warmtepomp
    command: 'python3 /usr/share/hassio/homeassistant/scripts/anna.py'
    value_template: "{{ value_json.waardes }}"

The current output from my anna.py script when run locally is:

{"waardes":{"temperatuur":19.36,"buiten_temperatuur":7.0,"thermostaat":19.0,"water_temperatuur":26.69,"verwarming":"off","warmtepomp":"off"}}

This results in the following log error/warning:

2018-12-29 23:28:09 ERROR (SyncWorker_13) [homeassistant.components.sensor.command_line] Command failed: python3 /usr/share/hassio/homeassistant/scripts/anna.py 
2018-12-29 23:28:09 WARNING (SyncWorker_13) [homeassistant.components.sensor.command_line] Empty reply found when expecting JSON data

Now Iā€™m a bit stumped what to do. After reading a lot of documentation and forum posts Iā€™m not sure how to proceed. Do I need to make custom / virtual sensors (how?) and fill those by letting the python script set them through the state machine? Or is there another way? Maybe involving MQTT?

I would like the sensors to be persistant and in the future expand functionality by also setting thermostat temperature through Home Asisstant.

Any help would be greatly apreciated!
My setup is Hass.io running in docker on Ubuntu 18.04.

I see now that using Hassio in combination with the Command Line Sensor is not as easy as I hoped.
Hassio - Run local scripts
Never the less I made it work :partying_face:

On my host I run the script which puts the values I need into specific files inside the homeassistant config subfolder and update/overwrites them every minute. Command Line Sensor works in Hassio, you just donā€™t have many programs to use (for example xml parser), but you do have things like cat so I can read the files. Therefore sensors like thisā€¦

sensor:
  - platform: command_line
    command: 'cat scripts/data/temperatuur'
    name: Woonkamer Temperatuur
    unit_of_measurement: "Ā°C"
    value_template: '{{ value | round(2) }}'

binary_sensor:
  - platform: command_line
    command: 'cat scripts/data/warmtepomp'
    name: Warmtepomp
    device_class: heat
    payload_on: "on"
    payload_off: "off"

gives me nice usable sensors:
afbeelding afbeelding

I know the best way would have been to setup a custom component or add-on but my Python skills are just not (yet) up for that. Als I havenā€™t had use for a MQTT broker and Iā€™m still a bit unsure about how I would have fixed this throug MQTT messages. I think the benefit would be that the sensors wouldnā€™t have to be polled but would be directly available after sensor update.

If anyone has any tips on how to improve this setup or wants to work on custom component for the Anna thermostat just let me know.

I just found https://github.com/laetificat/haanna.
Will try it this weekend myself. Just got my anna.

Hey guys. Iā€™m looking to buy a thermostat to use in conjunction with Homassistant. Anna is the front runner IF I can at least command if from Hass to shut off the heat. Ideally I would like to set the heat as well.

Does that work? As for your description it looks like you can only read it as a sensor.

Thanks in advance.

Hi,

Using the haanna library mentioned above, I am able to set the target temperature and current preset. I couldnā€™t find a way to load it into home assistant directly, so I created a small component to forward a few service calls to this library. Iā€™m hoping to find an easier way to set this upā€¦ but itā€™ll do for now.

1 Like

It looks doable. Thanks so much!

https://github.com/laetificat/anna-ha thats the component that goes along with it.

Hi guys, I am running home assistant on an UNRAID server so I was hoping someone would take the time to explain to me in a couple simple steps how to get anna working within home assistant.

Right now I am using domoticz to drive anna. Domoticz is synced with Home assistant over MQTT.

Now I have the following stats:

  • current thermostat setting in degrees
  • illuminance in lux of the front facing sensor
  • boiler temperature in degres
  • actual in room temperature measured by anna in degrees

I can send an MQTT message from home assistant adjusting the temperature, like this one:

   {
     "idx" : 3,
     "nvalue" : 0,
     "svalue" : "23.50"
    }

Loving the work of https://github.com/laetificat - Just installed Anna over here but didnā€™t get it quiet working on 0.91.2. Made some adjustments in https://github.com/laetificat/anna-ha/pull/1 to get met going, as included in the PR not sure if heater detection works, but at least youā€™ll get displayed in which mode Anna resides (i.e. preset ā€˜home/away/asleepā€™ ā€¦)

As an update, Iā€™ve created to PRs for both haanna and anna-ha (both in laetificatā€™s repo) to support showing (not yet setting) the operation_mode (i.e. schedule on/off) - it will display (state:on/off) if the heating is active - and switching presets (hold_mode) is working as well.

1 Like

I like the components so far, i did some changes to it and managed to get it to work on an adam too. i think the component might be named more global if it can support both anna and adam. With adam i know you can have multiple lisaā€™s. Does multiple work for that update too?

1 Like

As indicated by the author it might be possible, if you guys are indeed sharing the home city it might be easy to accomplish :slight_smile:

Hi, just bought an Anna. Now trying to integrate it in my HA system (hassio).
How do I install the haanna dependency exactly?
I keep getting:

Unable to install package haanna==0.6.2: Could not find a version that satisfies the requirement haanna==0.6.2 (from versions: 0.4.3, 0.5.0, 0.5.1, 0.6.1)
No matching distribution found for haanna==0.6.2

Iā€™ve put the haanna-files (the most recent onces, from the pull-request) and -dirs into the config/custom_components directory, no go.
Also I tried putting them in config/custom_components/anna directory, also no go.

Iā€™m on 0.92.2.

Hi @bouwew,

I prepped my PR for it to be ready (both haanna and anna-ha need updating) but the author hasnā€™t prepped them yet on pypi. What you can do is downgrade it to 0.6.1 (adjust the file manifest.json in your custom_components/anna directory) so it will install. Then apply my patches and you should be fine up to when the author has time to merge it.
(Sorry about the dependency but I didnā€™t see a way around it, as it (haanna) was only additions I hoped for a quick resolve)

Thank you!

After a few tries I got it working :smile:

@CoMPaTech, heater detection works for me, Iā€™ve seen the state to show ā€œonā€ when the heating is running.
Furthermore, in HA the following is shown:

climate.anna_thermostat  off	current_temperature: 21
                                min_temp: 4
                                max_temp: 30
                                temperature: 20
                                hold_mode: home
                                friendly_name: Anna Thermostat
                                icon: mdi:thermometer
                                supported_features: 257

I also have made a weekly schedule and enabled that.
Would it be possible to show this as well in the status?

I checked the code a bit, as I am getting a little familiar with parsing XML, I made my own HA-sensor for the AURUM meetstekker that I have at home, I might giving it a try to add some new feature, when I can find some time. Maybe borrow from domoticz: https://github.com/domoticz/domoticz/blob/2178bf5a8e81f0f17ed90674f0382036fa7570a6/hardware/AnnaThermostat.cpp

I already have reading and setting the presets sort-of-ready, but the domoticz part makes it a tiny bit easier. The bigger thing is waiting (or not?) for the original author, but we still could abuse the PR further, do you want commit permissions on my fork so we can work on it together?
Biggest ā€˜searchā€™ for me was to figure out how to handle presets (as in the schedules), also see my comments in the PR.

UPDATE: while actually trying this I found out that the login and password must be entered every time when a new browser session is opened :frowning:

Or, I was thinking, why not put the whole webpage in HA?

panel_iframe:
  anna:
    title: Plugwise Anna
    icon: mdi:thermometer
    url: http://192.168.xxx.yyy

There is a limitation, this only works when being connected to the home network.
There might be ways around this but I havenā€™t had time to investigateā€¦

Hi all, first of all, thanks for the great work on implementing this!
Im trying to add the thermostat myself using the latest PR and setting manifest.json to 0.6.1.
However, I get stuck with this error and I canā€™t seem to get around it:

Error while setting up platform anna
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/anna/climate.py", line 106, in setup_platform
config.get(CONF_MAX_TEMP)
  File "/config/custom_components/anna/climate.py", line 132, in __init__
self._api = haanna.Haanna(self._username, self._password, self._host, self._port)
TypeError: __init__() takes 4 positional arguments but 5 were given

I downgraded from 0.93.0 to 0.92.2, but this also does not seem to solve it. Any suggestions?

I encountered the same error. I ended up needing to edit the haanna.py file on my system, replacing the content by the updated content from the pull-request. Doing this can be a little complex when you are not familiar with how things ā€œwork under the hoodā€ā€¦