Owl Intuition pv & Home Assistant

Hi All.
It would be great if someone could create a script showing how to import data from th owl and build it into HA.

Here is a URL from Owl advising the code that can be used.

I have also seen that someone has been able to get the owl working with emoncms.
https://openenergymonitor.org/forum-archive/node/3302.html

This is my feature request. Thanks to all for creating this HA community.
mitch

Upvoted.

I’m interested too. I want to connect an owl micro (http://www.theowl.com/index.php/energy-monitors/standalone-monitors/owl-micro/) through an network owl (http://www.theowl.com/index.php/energy-monitors/ac/network-owl/). (I don’t want to use rfxcom and 433mhz)

@18days did you manage to make it work ?

Well I have a basic script for this working now…it is not fully integrated, but provides basic sensor input from the Multicast broadcast messages from the Network OWL.
The script as-is only supports the heating and hot water devices, but could be easily extended to cover solar PV (which I don’t have so are unable to test).

First of all a python script which captures the multicast messages and outputs as json:

import socket
import struct
import json
from xml.etree import ElementTree as ET

OWL_PORT = 22600
OWL_GROUP = "224.192.32.19"

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((OWL_GROUP, OWL_PORT))
mreq = struct.pack("=4sl", socket.inet_aton(OWL_GROUP), socket.INADDR_ANY)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)

while True:
    # Collect the XML multicast message
    xml, addr = sock.recvfrom(1024)
    # Parse the XML string
    root = ET.fromstring(xml)

    # Only process those messages we are interested in
    if root.tag == 'hot_water' or root.tag == 'heating':
    
        timestamp_value = 0
        timestamp = root.find('timestamp')
        if timestamp is not None:
            timestamp_value = int(timestamp.text)
    
        # iterate over each zone (Owl supports up to 4), but we don't distinguish
        for zone in root.iter('zone'):

            battery_value = 0
            battery = zone.find('battery')
            if battery is not None:
                battery_value = int(battery.attrib["level"])

            current_value = 0.0
            current = zone.find('temperature/current')
            if current is not None:
                current_value = float(current.text)

            required_value = 0.0
            required = zone.find('temperature/required')
            if required is not None:
                required_value = float(required.text)

            ambient_value = 0.0
            ambient = zone.find('temperature/ambient')
            if ambient is not None:
                ambient_value = float(ambient.text)

            print json.dumps({'device': root.tag, \
                        'timestamp': timestamp_value, \
                        'battery_level': battery_value, \
                        'current_temperature': current_value, \
                        'required_temperature': required_value, \
                        'ambient_temperature': ambient_value })

Then there is a bash script which takes the output of the above and publishes as MQTT messages with topic home/mcast/heating or home/mcast/hot_water.

#!/bin/sh
#
# owl_mcast2mqtt.sh
#
# Publish json output of the owl_mcast2json script to MQTT 
#
export LANG=C
PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"

MQTT_HOST="192.168.1.10"
MQTT_USER="homeassistant"
MQTT_PASS="SETPASSWORDHERE"

echo "OWL Network Multicast 2 MQTT"

python -u owl_mcast2json.py | while read line
do
	MQTT_TOPIC="home/mcast/$(echo $line | jq --raw-output '.device')"
	# Publish the json to the appropriate topic
	echo $line | mosquitto_pub -h $MQTT_HOST -u $MQTT_USER -P $MQTT_PASS -i OWL_MCast -r -l -t $MQTT_TOPIC
done

Finally a sensor in configuration.yaml to pickup the values, e.g.:

sensor:
  - platform: mqtt
    name: 'Owl Heating'
    state_topic: "home/mcast/heating"
    unit_of_measurement: '°C'
    value_template: '{{ value_json.current_temperature }}'

The approach is based on the rtl4332mqqt addon by James Fry.

1 Like

Hi there,

Maybe this is for the “Share your Projects!” category, anyway I have an OWL Intuition Power Meter in my house and I implemented a custom sensor in Home Assistant:

https://github.com/glpatcern/domotica/blob/master/homeass/code/owlintuition.py

I’m not using the UDP multicast, but rather the “push data” option from OWL. The sensor binds to a UDP port and then parses the received XML payload. Of course I only extracted the power meter data, but I guess this is easily extendable to other OWL devices (though I could not find any official documentation of the XML format - I just reverse engineered it).

One unresolved issue is that right now the sensor updates its state synchronously, which is not nice because it listens for UDP notifications that “only” come every minute, and plenty of warnings are (legitimately!) logged by HA. I’d like to make the implementation asynchronous: is there any guideline/documentation to implement async updates?

Once I resolve this I’ll consider contributing it via PR, but for now it can already be used.

Configuration example:

sensor:
  - platform: owlintuition
    port: 3200
    mode: triphase       # default is monophase
    monitored_conditions:
      - battery
      - radio
      - power
      - energy_today

I also created a templated sensor to group together the three phases:

sensor:
  - platform: template
    sensors:
      owl_meter_triphasepower:
        friendly_name: OWL Meter Triphase Power
        icon_template: mdi:flash
        value_template: "{{ states.sensor.owl_meter_power_P1.state }} W + {{ states.sensor.owl_meter_power_P2.state }} W + {{ states.sensor.owl_meter_power_P3.state }} W"

So I got a neat group looking like the following:

owl_meter_panel

Enjoy!

3 Likes

Hey @glopresti

Im kinda of new to the home Assistant community , and i can say im loving it.

I to have a owl intuition and running Hass.io and i can no for the love of god get them to work together.
Ive looked at your GitHub, and currently using your script (nice job btw). but im stuck.

Well here are my steps
-Ive gone to the owl intuition an pointed the push data UDP to my hass.io IP
-Installed your script in the config folder custom_components/sensor
-created the sensor and the group.

all apeares in the dashboard but as unknown.
41

and if i go to the logs i get these errors

2018-04-13 12:30:24 ERROR (SyncWorker_8) [custom_components.sensor.owlintuition] Unable to bind on port 3200: [Errno -2] Name does not resolve
2018-04-13 12:31:26 ERROR (SyncWorker_17) [custom_components.sensor.owlintuition] Unable to bind on port 3200: [Errno -2] Name does not resolve
2018-04-13 12:32:28 ERROR (SyncWorker_10) [custom_components.sensor.owlintuition] Unable to bind on port 3200: [Errno -2] Name does not resolve
2018-04-13 12:33:30 ERROR (SyncWorker_12) [custom_components.sensor.owlintuition] Unable to bind on port 3200: [Errno -2] Name does not resolve
2018-04-13 12:34:32 ERROR (SyncWorker_7) [custom_components.sensor.owlintuition] Unable to bind on port 3200: [Errno -2] Name does not resolve

what could i be missing, I’ve bean at it a few day and cannot figure it out.

Hi @australian,

The 'Name does not resolve' error suggests that from your hass.io you cannot resolve hostnames, but then I don’t understand how it can connect to other components: do you have other working sensors?
Anyway to further troubleshoot your setup, can you get a shell inside hass.io? (I don’t know the details of that, I personally use homeassistant inside a docker container)

If yes, try to launch python and then execute the following:

import socket
print socket.getfqdn()
print socket.gethostname()

I expect the getfqdn() to fail, but maybe gethostname() works and the OWL sensor could be adapted to use that. Also, you might hardcode the IP address of your hass.io (but I’d make it a configuration parameter - I can’t do this modification now but may work on that).

1 Like

I’m new to HA and have an Owl Intuition can anyone please help me get this working?

I’ve added the following to my configuration.yaml file:

>   - platform: owlintuition
>     port: 3200
>     mode: monophase       # default is monophase
>     monitored_conditions:
>       - battery
>       - radio
>       - power
>       - energy_today

I created a folder under my config folder called “customer_components\sensor” and copied the script from github to a file called owlintuition.py and placed it in the sensor folder.

I’m not sure what I need to do in the push data settings in the owl in the web interface, am I just pointing it at the internal IP of the HA instance?

When I add the above owl sensor to my configuration.yaml file and then check config it gets stuck and won’t validate the config or restart until I delete the sensor owl sensor from HA.

Any ideas please?

hi bcowell.

don’t know if you had any luck, but after a lot of help for glospresti have you tried using the sensor with this configuration

– platform: owlintuition
port: 3200
mode: monophase
host: (ip of HA)
monitored_conditions:
– battery
– power
– energy_today
– radio

Ive been away for a while. let me know if can help in getting yours to work

1 Like

No I gave up on it and couldn’t get it to work, thanks for replying!

I’ll give your config a go and reply back. Besides the config above I’ve put the owlintuition.py file in config\custom_components\sensor folder do I need to do anything on the owl device?

Hi there,

Sorry for having missed your first post, anyway a priori what you did is all correct (including the push settings in the OWL web interface). What do you see in the HA logs?

Also, can you make sure you are receiving data on the box where HA runs? To validate that, you may try and get the OWL data outside of HA. Try something like https://github.com/glpatcern/domotica/blob/master/demos/owlintuition.py

And finally, note that a recent update of the OWL firmware broke the XML format (but they should be deploying the fix, I got it after asking their support).

Hope this helps.

1 Like

It’s working now I just had to put the Host IP Address in configuration.yaml file. Thank you both for your help.

One more question, can I get this to show What my solar system is currently generating and total generation for today? How often does the data get refreshed?

1 Like

Good, thanks for reporting that.

For your questions: the data is refreshed every minute, and about your solar system, of course I can’t say. But if you have another current clamp on its output you should be able to get your data. You can play with my demo above to look at the full XML data and check what you have.

1 Like

Hi, to add to the above: I realized that OWL explicitly supports solar panel systems.
If you send me the XML you get e.g. by running my demo, I can try and integrate a sensor for the solar panel.

Yes I can see my Solar generation in the Owl app. How do I run the demo?

Simply run the script (python owlintuition.py) from the same box where you run HomeAssistant - stop HA if you wish to use the same port. Within a minute it will print the XML packet received from the OWL base station.

Yeah sorry no idea how to run it, I know nothing about python or how to run the script. I installed python on my windows desktop and pointed the push data settings on my owl to my windows desktop and run it but still not sure what I’m doing.

Hi
Did you have any luck moving to an async model?

Hi,

Nope. I got the solar generators supported thanks to @bcowell, but at that time my several attempts at getting the async way working failed both for me and for him - we had Home Assistant randomly crashing every couple of hours.

If you want to have a look at the last version, it’s here:

But despite not producing any error and working fine for some time, it crashes HA.

Thanks for the update, I’ve been playing with my setup and have discovered a number of idiosyncrasies with the OWL system that I thought worth mentioning in case it helps anyone else. I have two Network OWLs running at two different properties so have been able to identify a range of issues.

First of all the older generation of hardware used a fixed IP address for firmware updates. The company no longer controls that IP address and therefore the older hardware cannot be updated unless it received an interim firmware update while they still controlled the IP address.

The older generation hardware has a MAC address beginning ‘4337190’ and the newer generation MAC ID should start ‘4437191’. There is still stock on shelves with some retailers that is the old hardware so if buying a new device get them to check the MAC address before purchasing.

The older generation hardware latest firmware is 2.8:1096 whereas the new generation is at 4.3:608 and the XML that is transmitted is slightly different!

If you have an older Network OWL the XML format of the datagram does not have the version 2.0 attribute and is missing the tag, sample XML as follows:

<electricity id='44371900413F'>
	<timestamp>1537276490</timestamp>
	<signal rssi='-83' lqi='124'/>
	<battery level='100%'/>
	<chan id='0'>
		<curr units='w'>1094.00</curr>
		<day units='wh'>17120.14</day>
	</chan>
	<chan id='1'>
		<curr units='w'>0.00</curr>
		<day units='wh'>0.00</day>
	</chan>
	<chan id='2'>
		<curr units='w'>0.00</curr>
		<day units='wh'>0.00</day>
	</chan>
</electricity>

If you also have the heating controls from OWL, then additional datagrams are multicast between each update as follows:

> <heating ver='2' id='44371900413F'>
> 	<timestamp>1537276534</timestamp>
> 	<zones>
> 		<zone id='200167D' last='1'>
> 			<signal rssi='-79' lqi='49'/>
> 			<battery level='2780'/>
> 			<conf flags='0'/>
> 			<temperature state='0' flags='0' until='1537286400' zone='0'>
> 				<current>19.05</current>
> 				<required>15.00</required>
> 			</temperature>
> 		</zone>
> 	</zones>
> </heating>
> 
> <hot_water ver='2' id='44371900413F'>
> 	<timestamp>1537276511</timestamp>
> 	<zones>
> 		<zone id='200120B' last='1'>
> 			<signal rssi='-71' lqi='49'/>
> 			<battery level='2670'/>
> 			<conf flags='0'/>
> 			<temperature state='0' flags='0' until='1537282800'>
> 				<current>54.00</current>
> 				<required>10.00</required>
> 				<ambient>23.75</ambient>
> 			</temperature>
> 		</zone>
> 	</zones>
> </hot_water>
> 
> <relays var='1' id='44371900413F'>
> 	<timestamp>1537276470</timestamp>
> 	<zones>
> 		<zone id='2101FB8' last='1' relay='0'>
> 			<signal rssi='-87' lqi='49'/>
> 			<conf flags='0'/>
> 			<devices>
> 				<device address='200167D' relay='0' rssi='-75'/>
> 			</devices>
> 		</zone>
> 	</zones>
> </relays>