New integration: Energy monitoring device Circutor Wibeee

Hello,


Update Code is now stored in github:


I have been able to integrate following device in my home assistant configuration as custom sensor.

http://wibeee.circutor.com/index_en.html

Can anyone guide me how to share it so oder users can use or improve it?

Here is how it looks like:

Home_Assistant

Integration was really easy, as device provides all the information in following web service:

http://wibeee-host/en/status.xml

<response>
<fase1_vrms>240.71</fase1_vrms>
<fase1_irms>0.87</fase1_irms>
<fase1_p_aparent>208.51</fase1_p_aparent>
<fase1_p_activa>13.09</fase1_p_activa>
<fase1_p_reactiva_ind>199.32</fase1_p_reactiva_ind>
<fase1_p_reactiva_cap>0.00</fase1_p_reactiva_cap>
<fase1_frecuencia>50.02</fase1_frecuencia>
<fase1_factor_potencia>-0.063</fase1_factor_potencia>
<fase1_energia_activa>79095.77</fase1_energia_activa>
<fase1_energia_reactiva_ind>211765.70</fase1_energia_reactiva_ind>
<fase1_energia_reactiva_cap>41880.75</fase1_energia_reactiva_cap>
<fase2_vrms>241.04</fase2_vrms>
<fase2_irms>1.18</fase2_irms>
<fase2_p_aparent>283.87</fase2_p_aparent>
<fase2_p_activa>274.44</fase2_p_activa>
<fase2_p_reactiva_ind>0.00</fase2_p_reactiva_ind>
<fase2_p_reactiva_cap>0.00</fase2_p_reactiva_cap>
<fase2_frecuencia>50.00</fase2_frecuencia>
<fase2_factor_potencia>0.967</fase2_factor_potencia>
<fase2_energia_activa>758287.36</fase2_energia_activa>
<fase2_energia_reactiva_ind>35490.79</fase2_energia_reactiva_ind>
<fase2_energia_reactiva_cap>20987.15</fase2_energia_reactiva_cap>
<fase3_vrms>240.25</fase3_vrms>
<fase3_irms>0.57</fase3_irms>
<fase3_p_aparent>136.68</fase3_p_aparent>
<fase3_p_activa>75.79</fase3_p_activa>
<fase3_p_reactiva_ind>0.00</fase3_p_reactiva_ind>
<fase3_p_reactiva_cap>-99.08</fase3_p_reactiva_cap>
<fase3_frecuencia>50.02</fase3_frecuencia>
<fase3_factor_potencia>0.555</fase3_factor_potencia>
<fase3_energia_activa>127173.91</fase3_energia_activa>
<fase3_energia_reactiva_ind>1051.21</fase3_energia_reactiva_ind>
<fase3_energia_reactiva_cap>98411.14</fase3_energia_reactiva_cap>
<fase4_vrms>240.67</fase4_vrms>
<fase4_irms>0.87</fase4_irms>
<fase4_p_aparent>629.06</fase4_p_aparent>
<fase4_p_activa>337.15</fase4_p_activa>
<fase4_p_reactiva_ind>0.00</fase4_p_reactiva_ind>
<fase4_p_reactiva_cap>-298.40</fase4_p_reactiva_cap>
<fase4_frecuencia>50.02</fase4_frecuencia>
<fase4_factor_potencia>0.536</fase4_factor_potencia>
<fase4_energia_activa>964557.04</fase4_energia_activa>
<fase4_energia_reactiva_ind>248307.70</fase4_energia_reactiva_ind>
<fase4_energia_reactiva_cap>161279.04</fase4_energia_reactiva_cap>
</response>

And following is the custom sensor that I used: custom_components/sensor/wibeee.py

""" Suport for Circutor Energy consumption analyzer http://wibeee.circutor.com/

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.circutor_wibeee/ (ToDO)
"""

import logging
from datetime import timedelta

import voluptuous as vol

from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
    CONF_NAME, CONF_HOST, CONF_SCAN_INTERVAL)
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv

import requests
from xml.etree import ElementTree
from requests.auth import HTTPBasicAuth, HTTPDigestAuth

_LOGGER = logging.getLogger(__name__)
_RESOURCE = 'http://{}/en/status.xml'
url = ""


DEFAULT_METHOD = 'GET'
DEFAULT_NAME = 'Wibeee Energy Consumption Sensor'


MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)   # Default value

SENSOR_TYPES = {
    'vrms': ['Vrms', 'V'],
    'irms': ['Irms', 'A'],
    'frecuencia': ['Frequency', 'Hz'],
    'p_activa': ['Active Power', 'W'],
    'p_reactiva_ind': ['Inductive Reactive Power', 'VArL'],
    'p_reactiva_cap': ['Capacitive Reactive Power', 'VArC'],
    'p_aparent': ['Apparent Power', 'VA'],
    'factor_potencia': ['Power Factor', ' '],
    'energia_activa': ['Active Energy', 'Wh'],
    'energia_reactiva_ind': ['Inductive Reactive Energy', 'VArLh'],
    'energia_reactiva_cap': ['Capacitive Reactive Energy', 'VArCh']
}


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the RESTful sensor."""
    name = config.get(CONF_NAME)
    host = config.get(CONF_HOST)
    scan_interval = config.get(CONF_SCAN_INTERVAL)


    # Create a data fetcher. Then make first call
    try:
        wibeee_data = WibeeeData(host, scan_interval)
    except ValueError as error:
        _LOGGER.error(error)
        return False


    _LOGGER.info("Response: %s", wibeee_data.data)
    tree = ElementTree.fromstring(wibeee_data.data)

    devices = []
    for item in tree:
        sensor_id = item.tag
        sensor_phase,sensor_name = item.tag.split("_",1)
        sensor_phase = sensor_phase.replace("fase","")
        sensor_value = item.text

        _LOGGER.info("Adding sensor %s with value %s", sensor_id, sensor_value)

        devices.append(WibeeeSensor(hass, wibeee_data, name, sensor_id, sensor_phase, sensor_name,sensor_value))

    add_devices(devices, True)



class WibeeeSensor(Entity):
    """Implementation of Wibeee sensor."""

    def __init__(self, hass, wibeee_data, name, sensor_id, sensor_phase, sensor_name, sensor_value):
        """Initialize the sensor."""
        self._hass = hass
        self.wibeee_data = wibeee_data
        self._sensor_id = sensor_id
        self._type = name
        self._sensor_phase = "Phase" + sensor_phase
        self._sensor_name = SENSOR_TYPES[sensor_name][0].replace(" ", "_")
        self._state = sensor_value
        self._unit_of_measurement = SENSOR_TYPES[sensor_name][1]

    @property
    def name(self):
        """Return the name of the sensor."""
        return self._type + "_" + self._sensor_phase + "_" + self._sensor_name

    @property
    def unit_of_measurement(self):
        """Return the unit the value is expressed in."""
        return self._unit_of_measurement

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    def update(self):
        """Get the latest data from API and updates the states."""
        # Call the API for new data. Each sensor will re-trigger this
        # same exact call, but that's fine. Results should be cached for
        # a short period of time to prevent hitting API limits.
        self.wibeee_data.update()

        try:
            tree = ElementTree.fromstring(self.wibeee_data.data)

            for item in tree:

                sensor_id = item.tag
                sensor_value = item.text

                if sensor_id == self._sensor_id:
                   self._state = sensor_value

        except:
            _LOGGER.warning("Could not update status for %s", self._sensor_id)


class WibeeeData(object):
    """Gets the latest data from HP ILO."""

    def __init__(self, host, scan_interval):
        """Initialize the data object."""
        self._host = host
        self._url = _RESOURCE.format(host)
        self._scan_interval = scan_interval
        #MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=int(self._scan_interval))

        self.data = None

        self.update()

    @Throttle(MIN_TIME_BETWEEN_UPDATES)
    def update(self):
        """Get the latest data"""

        try:
            response = requests.get(self._url, timeout=10)
            self.data = response.content
        except ValueError as error:
            raise ValueError("Unable to obtain any response from %s, %s", self._url, error)

4 Likes

Wow, wish those were forsale in the states and would work for 240, 60hz single phase.

There is one for single phase too, the sensor I created was only only tested with 3 phases.

I have not idea if this is for sale in US but from their specifications it should work:

http://circutor.es/docs/FT_Wi-Beee_EN.pdf

Great example JuanjoSanz! I am struggling to undertand how the wibeee.py code interact with the device itself, how does it work? I am quite new to this world and I cannot find how it works. I am thinking to create a custom device from a raspberry pi zero

thks!

Information is exposed in a web interface, what the code does is just to read whole xml and parse each item into a variable that is refreshed periodically.

I would like to integrate officially into home-assistant but I have not the time and neither experience doing that, Could any one help me with its integration?

By the way, you can use it as custom component pasting source code into “custom_components/sensor/wibeee.py”

And adding it to configuration.yaml

- platform: wibeee
  name: "Wibeee"
  host: 192.168.xx.xx
  scan_interval: 5

Hi JuanjoSanz, I’m trying to implement this to my HA, but I cant understand all the things that I have to do, could you specify in more details what you did to get it done?, btw I’m a new user on HA world hehehe.

Thanks in advance

I reply my self, to help others, I was getting this error on HA:

, so I decided to find out what was happening (I’m not a programmer, neither Python expert), so I tried several times in many ways until I could find the problem, the XML parser was getting the <coilStatus> and <scale> without second Value, so what I did was remove them in the code. this is the final code:


import logging
from datetime import timedelta

import voluptuous as vol

from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
    CONF_NAME, CONF_HOST, CONF_SCAN_INTERVAL)
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv

import requests
from xml.etree import ElementTree
from requests.auth import HTTPBasicAuth, HTTPDigestAuth

_LOGGER = logging.getLogger(__name__)
_RESOURCE = 'http://{}/en/status.xml'
url = ""


DEFAULT_METHOD = 'GET'
DEFAULT_NAME = 'Wibeee Energy Consumption Sensor'


MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)   # Default value

SENSOR_TYPES = {
    'vrms': ['Vrms', 'V'],
    'irms': ['Irms', 'A'],
    'frecuencia': ['Frequency', 'Hz'],
    'p_activa': ['Active Power', 'W'],
    'p_reactiva_ind': ['Inductive Reactive Power', 'VArL'],
    'p_reactiva_cap': ['Capacitive Reactive Power', 'VArC'],
    'p_aparent': ['Apparent Power', 'VA'],
    'factor_potencia': ['Power Factor', ' '],
    'energia_activa': ['Active Energy', 'Wh'],
    'energia_reactiva_ind': ['Inductive Reactive Energy', 'VArLh'],
    'energia_reactiva_cap': ['Capacitive Reactive Energy', 'VArCh']
}


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the RESTful sensor."""
    name = config.get(CONF_NAME)
    host = config.get(CONF_HOST)
    scan_interval = config.get(CONF_SCAN_INTERVAL)


    # Create a data fetcher. Then make first call
    try:
        wibeee_data = WibeeeData(host, scan_interval)
    except ValueError as error:
        _LOGGER.error(error)
        return False


    _LOGGER.info("Response: %s", wibeee_data.data)
    tree = ElementTree.fromstring(wibeee_data.data)

    devices = []
    for item in tree:
            for subitem in tree.findall('coilStatus') or tree.findall('scale') :
                tree.remove(subitem)
            sensor_id = item.tag
            sensor_phase,sensor_name = item.tag.split("_",1)
            sensor_phase = sensor_phase.replace("fase","")
            sensor_value = item.text

            _LOGGER.info("Adding sensor %s with value %s", sensor_id, sensor_value)

            devices.append(WibeeeSensor(hass, wibeee_data, name, sensor_id, sensor_phase, sensor_name,sensor_value))

    add_devices(devices, True)



class WibeeeSensor(Entity):
    """Implementation of Wibeee sensor."""

    def __init__(self, hass, wibeee_data, name, sensor_id, sensor_phase, sensor_name, sensor_value):
        """Initialize the sensor."""
        self._hass = hass
        self.wibeee_data = wibeee_data
        self._sensor_id = sensor_id
        self._type = name
        self._sensor_phase = "Phase" + sensor_phase
        self._sensor_name = SENSOR_TYPES[sensor_name][0].replace(" ", "_")
        self._state = sensor_value
        self._unit_of_measurement = SENSOR_TYPES[sensor_name][1]

    @property
    def name(self):
        """Return the name of the sensor."""
        return self._type + "_" + self._sensor_phase + "_" + self._sensor_name

    @property
    def unit_of_measurement(self):
        """Return the unit the value is expressed in."""
        return self._unit_of_measurement

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    def update(self):
        """Get the latest data from API and updates the states."""
        # Call the API for new data. Each sensor will re-trigger this
        # same exact call, but that's fine. Results should be cached for
        # a short period of time to prevent hitting API limits.
        self.wibeee_data.update()

        try:
            tree = ElementTree.fromstring(self.wibeee_data.data)

            for item in tree:

                sensor_id = item.tag
                sensor_value = item.text

                if sensor_id == self._sensor_id:
                   self._state = sensor_value

        except:
            _LOGGER.warning("Could not update status for %s", self._sensor_id)


class WibeeeData(object):
    """Gets the latest data from HP ILO."""

    def __init__(self, host, scan_interval):
        """Initialize the data object."""
        self._host = host
        self._url = _RESOURCE.format(host)
        self._scan_interval = scan_interval
        #MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=int(self._scan_interval))

        self.data = None

        self.update()

    @Throttle(MIN_TIME_BETWEEN_UPDATES)
    def update(self):
        """Get the latest data"""

        try:
            response = requests.get(self._url, timeout=10)
            self.data = response.content
        except ValueError as error:
            raise ValueError("Unable to obtain any response from %s, %s", self._url, error)```
1 Like

Hi! Which wibeee device do you have? Notice that my development was for the 3 phase device. If you have one phase, other person made the adaption of my code, I don’t find it right now, but it should be somewhere in this forum.

I have the Mirubee Mirubox MONO, it seems to work fine right now, is it possible to you to upload the config.yaml of the custom tab “SUPPLIES”.

Thanks :slight_smile:

2 Likes

Nice to hear that my implementation does work with more similar devices, at the end, it is not much as an XML parser (taken from a web service)

I would really like to make this official in Home Assistant but for that I need some help as this was my first dev, and currently I have not even a single minute free.

About View Config, sure, here you go:

groups.yaml

supplies_view:
  view: yes
  name: Supplies
  #icon: mdi:network
  entities:
    - group.wibeee_phase1
    - group.wibeee_phase2
    - group.wibeee_phase3
    - group.wibeee_phase4

....
....


wibeee_phase1:
  name: 'Wibeee Phase 1'
  entities:
    - sensor.wibeee_phase1_active_energy
    - sensor.wibeee_phase1_active_power
    - sensor.wibeee_phase1_apparent_power
    - sensor.wibeee_phase1_capacitive_reactive_energy
    - sensor.wibeee_phase1_capacitive_reactive_power
    - sensor.wibeee_phase1_frequency
    - sensor.wibeee_phase1_inductive_reactive_energy
    - sensor.wibeee_phase1_inductive_reactive_power
    - sensor.wibeee_phase1_irms
    - sensor.wibeee_phase1_power_factor
    - sensor.wibeee_phase1_vrms
wibeee_phase2:
  name: 'Wibeee Phase 2'
  entities:
    - sensor.wibeee_phase2_active_energy
    - sensor.wibeee_phase2_active_power
    - sensor.wibeee_phase2_apparent_power
    - sensor.wibeee_phase2_capacitive_reactive_energy
    - sensor.wibeee_phase2_capacitive_reactive_power
    - sensor.wibeee_phase2_frequency
    - sensor.wibeee_phase2_inductive_reactive_energy
    - sensor.wibeee_phase2_inductive_reactive_power
    - sensor.wibeee_phase2_irms
    - sensor.wibeee_phase2_power_factor
    - sensor.wibeee_phase2_vrms
wibeee_phase3:
  name: 'Wibeee Phase 3'
  entities:
    - sensor.wibeee_phase3_active_energy
    - sensor.wibeee_phase3_active_power
    - sensor.wibeee_phase3_apparent_power
    - sensor.wibeee_phase3_capacitive_reactive_energy
    - sensor.wibeee_phase3_capacitive_reactive_power
    - sensor.wibeee_phase3_frequency
    - sensor.wibeee_phase3_inductive_reactive_energy
    - sensor.wibeee_phase3_inductive_reactive_power
    - sensor.wibeee_phase3_irms
    - sensor.wibeee_phase3_power_factor
    - sensor.wibeee_phase3_vrms
wibeee_phase4:
  name: 'Wibeee Phase 4 = Total'
  entities:
    - sensor.wibeee_phase4_active_energy
    - sensor.wibeee_phase4_active_power
    - sensor.wibeee_phase4_apparent_power
    - sensor.wibeee_phase4_capacitive_reactive_energy
    - sensor.wibeee_phase4_capacitive_reactive_power
    - sensor.wibeee_phase4_frequency
    - sensor.wibeee_phase4_inductive_reactive_energy
    - sensor.wibeee_phase4_inductive_reactive_power
    - sensor.wibeee_phase4_irms
    - sensor.wibeee_phase4_power_factor
    - sensor.wibeee_phase4_vrms
2 Likes

Hi all,

Here is the configuration for the monophase with some changes compared to the juanjoSanz’s one

""" Suport for Circutor Energy consumption analyzer http://wibeee.circutor.com/

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.circutor_wibeee/ (ToDO)
"""

import logging
from datetime import timedelta

import voluptuous as vol

from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (CONF_NAME, CONF_HOST, CONF_SCAN_INTERVAL)
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv

import requests
from xml.etree import ElementTree
from requests.auth import HTTPBasicAuth, HTTPDigestAuth

_LOGGER = logging.getLogger(__name__)
_RESOURCE = 'http://{}/en/status.xml'
url = ""

CONF_PHASES = "phases"
DEFAULT_PHASES = 3
DEFAULT_SCAN_INTERVAL = 10
DEFAULT_METHOD = 'GET'
DEFAULT_NAME = 'Wibeee Energy Consumption Sensor'


MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)   # Default value

SENSOR_TYPES = {
    'vrms': ['Vrms', 'V'],
    'irms': ['Irms', 'A'],
    'frecuencia': ['Frequency', 'Hz'],
    'p_activa': ['Active Power', 'W'],
    'p_reactiva_ind': ['Inductive Reactive Power', 'VArL'],
    'p_reactiva_cap': ['Capacitive Reactive Power', 'VArC'],
    'p_aparent': ['Apparent Power', 'VA'],
    'factor_potencia': ['Power Factor', 'PF'],
    'energia_activa': ['Active Energy', 'Wh'],
    'energia_reactiva_ind': ['Inductive Reactive Energy', 'VArLh'],
    'energia_reactiva_cap': ['Capacitive Reactive Energy', 'VArCh']
}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_PHASES, default=DEFAULT_PHASES): int,
})

def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the RESTful sensor."""
    name = config.get(CONF_NAME)
    host = config.get(CONF_HOST)
    scan_interval = config.get(CONF_SCAN_INTERVAL)
    phases = config.get(CONF_PHASES)

    # Create a data fetcher. Then make first call
    try:
        wibeee_data = WibeeeData(host, scan_interval)
    except ValueError as error:
        _LOGGER.error(error)
        return False


    _LOGGER.info("Response: %s", wibeee_data.data)
    tree = ElementTree.fromstring(wibeee_data.data)

    devices = []

    for item in tree:
        sensor_id = item.tag
        sensor_phase,sensor_name = item.tag.split("_",1)
        sensor_phase = sensor_phase.replace("fase","")
        if int(sensor_phase) > phases:
            break
        sensor_value = item.text

        _LOGGER.info("Adding sensor %s with value %s", sensor_id, sensor_value)

        wanted_parameters = ["vrms", "irms", "frecuencia", "p_activa"]
        if sensor_name in wanted_parameters:
            devices.append(WibeeeSensor(hass, wibeee_data, name, sensor_id, sensor_phase, sensor_name,sensor_value))

    add_devices(devices, True)



class WibeeeSensor(Entity):
    """Implementation of Wibeee sensor."""

    def __init__(self, hass, wibeee_data, name, sensor_id, sensor_phase, sensor_name, sensor_value):
        """Initialize the sensor."""
        self._hass = hass
        self.wibeee_data = wibeee_data
        self._sensor_id = sensor_id
        self._type = name
        self._sensor_phase = "Phase" + sensor_phase
        self._sensor_name = SENSOR_TYPES[sensor_name][0].replace(" ", "_")
        self._state = sensor_value
        self._unit_of_measurement = SENSOR_TYPES[sensor_name][1]

    @property
    def name(self):
        """Return the name of the sensor."""
        return self._type + "_" + self._sensor_phase + "_" + self._sensor_name

    @property
    def unit_of_measurement(self):
        """Return the unit the value is expressed in."""
        return self._unit_of_measurement

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    def update(self):
        """Get the latest data from API and updates the states."""
        # Call the API for new data. Each sensor will re-trigger this
        # same exact call, but that's fine. Results should be cached for
        # a short period of time to prevent hitting API limits.
        self.wibeee_data.update()

        try:
            tree = ElementTree.fromstring(self.wibeee_data.data)

            for item in tree:

                sensor_id = item.tag
                sensor_value = item.text

                if sensor_id == self._sensor_id:
                   self._state = sensor_value

        except:
            _LOGGER.warning("Could not update status for %s", self._sensor_id)


class WibeeeData(object):
    """Gets the latest data from HP ILO."""

    def __init__(self, host, scan_interval):
        """Initialize the data object."""
        self._host = host
        self._url = _RESOURCE.format(host)
        self._scan_interval = scan_interval
        #MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=int(self._scan_interval))

        self.data = None

        self.update()

    @Throttle(MIN_TIME_BETWEEN_UPDATES)
    def update(self):
        """Get the latest data"""

        try:
            response = requests.get(self._url, timeout=10)
            self.data = response.content
        except ValueError as error:
            raise ValueError("Unable to obtain any response from %s, %s", self._url, error)

In line 85 you can find a list of desired parametiers to show:

wanted_parameters = ["vrms", "irms", "frecuencia", "p_activa"]

To integrate it, add to sensor.yaml:

- platform: wibeee
  name: Wibeee
  host: 192.168.31.150
  phases: 1
1 Like

Hi, I have a mirubee (wibeee), to see if I can make it work, it’s great work they’re doing. Thank you

1 Like

hi, i can´t get make work it, if i try juanjo code, log says:

`

2019-01-14 00:01:05 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform wibeee
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 384, in _make_request
six.raise_from(e, None)
File “”, line 2, in raise_from
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 380, in _make_request
httplib_response = conn.getresponse()
File “/usr/lib/python3.5/http/client.py”, line 1198, in getresponse
response.begin()
File “/usr/lib/python3.5/http/client.py”, line 297, in begin
version, status, reason = self._read_status()
File “/usr/lib/python3.5/http/client.py”, line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), “iso-8859-1”)
File “/usr/lib/python3.5/socket.py”, line 576, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/requests/adapters.py”, line 449, in send
timeout=timeout
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/util/retry.py”, line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/packages/six.py”, line 686, in reraise
raise value
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 386, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 306, in _raise_timeout
raise ReadTimeoutError(self, url, “Read timed out. (read timeout=%s)” % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host=‘192.168.1.11’, port=80): Read timed out. (read timeout=10)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/lib/python3.5/asyncio/tasks.py”, line 400, in wait_for
return fut.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/sensor/wibeee.py”, line 52, in setup_platform
wibeee_data = WibeeeData(host, scan_interval)
File “/home/homeassistant/.homeassistant/custom_components/sensor/wibeee.py”, line 141, in init
self.update()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/init.py”, line 324, in wrapper
result = method(*args, **kwargs)
File “/home/homeassistant/.homeassistant/custom_components/sensor/wibeee.py”, line 148, in update
response = requests.get(self._url, timeout=10)
File “/srv/homeassistant/lib/python3.5/site-packages/requests/api.py”, line 75, in get
return request(‘get’, url, params=params, **kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/requests/api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/requests/adapters.py”, line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host=‘192.168.1.11’, port=80): Read timed out. (read timeout=10)

if i try oscar code i have juanjo´s problem:

`2019-01-14 00:11:50 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform wibeee
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/lib/python3.5/asyncio/tasks.py”, line 400, in wait_for
return fut.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self.exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/sensor/wibeee.py”, line 77, in setup_platform
sensor_phase,sensor_name = item.tag.split("
",1)
ValueError: not enough values to unpack (expected 2, got 1)´

sorry, i am new in this, and i don´t know where can be the problem.

1 Like

Just check first if you can reach device with a browser using following URL,

If so, just check if xml tags/attrib/… are the same that I showed in first post.

yes, i can,

if i do a homeassistant start log, i see like HA begin reading wibeee data until error…

my XML includes some more data that yours… :

<response>
<model> WBB</model>
<webversion>4.4.094</webversion>
<time>1547651473</time>
<fase1_vrms>213.55</fase1_vrms>
<fase1_irms>1.14</fase1_irms>
<fase1_p_aparent>243.69</fase1_p_aparent>
<fase1_p_activa>237.85</fase1_p_activa>
<fase1_p_reactiva_ind>0.00</fase1_p_reactiva_ind>
<fase1_p_reactiva_cap>0.00</fase1_p_reactiva_cap>
<fase1_frecuencia>50.31</fase1_frecuencia>
<fase1_factor_potencia>0.976</fase1_factor_potencia>
<fase1_energia_activa>91144</fase1_energia_activa>
<fase1_energia_reactiva_ind>13380</fase1_energia_reactiva_ind>
<fase1_energia_reactiva_cap>8142</fase1_energia_reactiva_cap>
<fase1_angle>0.00</fase1_angle>
<fase1_thd_total>0.00</fase1_thd_total>
<fase1_thd_fund>1.10</fase1_thd_fund>
<fase1_thd_ar3>0.00</fase1_thd_ar3>
<fase1_thd_ar5>0.00</fase1_thd_ar5>
<fase1_thd_ar7>0.00</fase1_thd_ar7>
<fase1_thd_ar9>0.00</fase1_thd_ar9>
<fase1_thd_tot_V>0.00</fase1_thd_tot_V>
<fase1_thd_fun_V>213.20</fase1_thd_fun_V>
<fase1_thd_ar3_V>0.00</fase1_thd_ar3_V>
<fase1_thd_ar5_V>0.00</fase1_thd_ar5_V>
<fase1_thd_ar7_V>0.00</fase1_thd_ar7_V>
<fase1_thd_ar9_V>0.00</fase1_thd_ar9_V>
<fase2_vrms>213.55</fase2_vrms>
<fase2_irms>0.32</fase2_irms>
<fase2_p_aparent>67.37</fase2_p_aparent>
<fase2_p_activa>0.00</fase2_p_activa>
<fase2_p_reactiva_ind>0.00</fase2_p_reactiva_ind>
<fase2_p_reactiva_cap>0.00</fase2_p_reactiva_cap>
<fase2_frecuencia>50.31</fase2_frecuencia>
<fase2_factor_potencia>0.000</fase2_factor_potencia>
<fase2_energia_activa>485</fase2_energia_activa>
<fase2_energia_reactiva_ind>2505</fase2_energia_reactiva_ind>
<fase2_energia_reactiva_cap>480</fase2_energia_reactiva_cap>
<fase2_angle>0.00</fase2_angle>
<fase2_thd_total>0.00</fase2_thd_total>
<fase2_thd_fund>0.00</fase2_thd_fund>
<fase2_thd_ar3>0.00</fase2_thd_ar3>
<fase2_thd_ar5>0.00</fase2_thd_ar5>
<fase2_thd_ar7>0.00</fase2_thd_ar7>
<fase2_thd_ar9>0.00</fase2_thd_ar9>
<fase2_thd_tot_V>0.00</fase2_thd_tot_V>
<fase2_thd_fun_V>213.20</fase2_thd_fun_V>
<fase2_thd_ar3_V>0.00</fase2_thd_ar3_V>
<fase2_thd_ar5_V>0.00</fase2_thd_ar5_V>
<fase2_thd_ar7_V>0.00</fase2_thd_ar7_V>
<fase2_thd_ar9_V>0.00</fase2_thd_ar9_V>
<fase3_vrms>213.55</fase3_vrms>
<fase3_irms>0.31</fase3_irms>
<fase3_p_aparent>65.28</fase3_p_aparent>
<fase3_p_activa>0.00</fase3_p_activa>
<fase3_p_reactiva_ind>0.00</fase3_p_reactiva_ind>
<fase3_p_reactiva_cap>0.00</fase3_p_reactiva_cap>
<fase3_frecuencia>50.31</fase3_frecuencia>
<fase3_factor_potencia>0.000</fase3_factor_potencia>
<fase3_energia_activa>359</fase3_energia_activa>
<fase3_energia_reactiva_ind>2137</fase3_energia_reactiva_ind>
<fase3_energia_reactiva_cap>437</fase3_energia_reactiva_cap>
<fase3_angle>0.00</fase3_angle>
<fase3_thd_total>0.00</fase3_thd_total>
<fase3_thd_fund>0.00</fase3_thd_fund>
<fase3_thd_ar3>0.00</fase3_thd_ar3>
<fase3_thd_ar5>0.00</fase3_thd_ar5>
<fase3_thd_ar7>0.00</fase3_thd_ar7>
<fase3_thd_ar9>0.00</fase3_thd_ar9>
<fase3_thd_tot_V>0.00</fase3_thd_tot_V>
<fase3_thd_fun_V>213.20</fase3_thd_fun_V>
<fase3_thd_ar3_V>0.00</fase3_thd_ar3_V>
<fase3_thd_ar5_V>0.00</fase3_thd_ar5_V>
<fase3_thd_ar7_V>0.00</fase3_thd_ar7_V>
<fase3_thd_ar9_V>0.00</fase3_thd_ar9_V>
<fase4_vrms>214.41</fase4_vrms>
<fase4_irms>1.93</fase4_irms>
<fase4_p_aparent>413.60</fase4_p_aparent>
<fase4_p_activa>247.11</fase4_p_activa>
<fase4_p_reactiva_ind>0.00</fase4_p_reactiva_ind>
<fase4_p_reactiva_cap>82.15</fase4_p_reactiva_cap>
<fase4_frecuencia>51.01</fase4_frecuencia>
<fase4_factor_potencia>0.597</fase4_factor_potencia>
<fase4_energia_activa>91989</fase4_energia_activa>
<fase4_energia_reactiva_ind>18023</fase4_energia_reactiva_ind>
<fase4_energia_reactiva_cap>9060</fase4_energia_reactiva_cap>
<scale>100</scale>
<coilStatus>-</coilStatus>
<ground>0.00</ground>
<
/response>

1 Like

I’ve got it, if you compare your xml with mine…

mine has only values of the type <faseX_name>value</faseX_name> → therefore I have a parsing to get phase number and name with following code:

sensor_phase,sensor_name = item.tag.split(“_”,1)

I see here two approaches,

  1. ignore those values
  2. parse them as phase = none / name = item.tag

it would be something like;

try:
sensor_phase,sensor_name = item.tag.split(“_”,1)
… paste here the other code inside for loop
except:
continue;

1 Like

yes, you are right,
i need more help for solve it, sorry :frowning: I am really noob.

i tried including your code, like this:

    for item in tree:
    sensor_id = item.tag
    sensor_phase,sensor_name = item.tag.split("_",1)
except:
    "model"
    "webversion"
    "time"
    "scale"
    "coilstatus"
    "ground"
continue;
    sensor_phase = sensor_phase.replace("fase","")
    if int(sensor_phase) > phases:

but log says syntax error, how would be right? thanks!

Try following code, unfortunatelly I have not the time to do it right … I would like to create a github repo and upload all those changes, and then try to add it officially to Home Assistant. For that please keep testing the code in all your devices, it seems it can be tuned to work with all circuitor devices (wibeee, mirubee,…)

devices = []
for item in tree:
    try:
      sensor_id = item.tag
      sensor_phase,sensor_name = item.tag.split("_",1)
      sensor_phase = sensor_phase.replace("fase","")
      sensor_value = item.text

      _LOGGER.info("Adding sensor %s with value %s", sensor_id, sensor_value)

      devices.append(WibeeeSensor(hass, wibeee_data, name, sensor_id, sensor_phase, sensor_name,sensor_value))
    except:
        pass

add_devices(devices, True)

It works! :hushed:

1 Like

Finally I’ve got a few minutes to upload this component in github.

I’ve even created some branches with the improvements in the code such as support for 1 phase devices.

2 Likes