Ebusd integration (#19607)
* ebusd component and sensor splitted ebusd component and sensor splitted and tested * houndci-bot fixes * pep8 validated * Update requirements_all.txt * travis fixes * Fix __init__.py for travis * translation updated * proposed changed * move logic from component to ebusdpy lib * hound fixes * Update requirements_all.txt * update pypi library to V0.0.11 * error management in command_result Avoid sensor status change in case an error in reading occurs * add opMode translations add opMode translations * send type to read ebusdpy API * timeframe as attribute for time schedule type sensors * hound fix * bugfix on library * ebusd sensor moved to ebusd component directory * update ebusdpy dependency * improvement proposed * travis fix * update error managing * insert log debug start setup * changes requested * exception tuple on init * cla-bot stucked pull * added bai circuit support * merged coveragerc from dev * configuration get change
This commit is contained in:
1 parent
8f249f9149
commit
fd991bd1a4
9 files changed
+354
-1
No files matched your search
@@ -0,0 +1,105 @@
|
||||
"""
|
||||
Support for Ebusd daemon for communication with eBUS heating systems.
|
||||
|
||||
For more details about ebusd deamon, please refer to the documentation at
|
||||
https://github.com/john30/ebusd
|
||||
"""
|
||||
|
||||
import logging
|
||||
import datetime
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
DEPENDENCIES = ['ebusd']
|
||||
|
||||
TIME_FRAME1_BEGIN = 'time_frame1_begin'
|
||||
TIME_FRAME1_END = 'time_frame1_end'
|
||||
TIME_FRAME2_BEGIN = 'time_frame2_begin'
|
||||
TIME_FRAME2_END = 'time_frame2_end'
|
||||
TIME_FRAME3_BEGIN = 'time_frame3_begin'
|
||||
TIME_FRAME3_END = 'time_frame3_end'
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Ebus sensor."""
|
||||
ebusd_api = hass.data[DOMAIN]
|
||||
monitored_conditions = discovery_info['monitored_conditions']
|
||||
name = discovery_info['client_name']
|
||||
|
||||
dev = []
|
||||
for condition in monitored_conditions:
|
||||
dev.append(EbusdSensor(
|
||||
ebusd_api, discovery_info['sensor_types'][condition], name))
|
||||
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class EbusdSensor(Entity):
|
||||
"""Ebusd component sensor methods definition."""
|
||||
|
||||
def __init__(self, data, sensor, name):
|
||||
"""Initialize the sensor."""
|
||||
self._state = None
|
||||
self._client_name = name
|
||||
self._name, self._unit_of_measurement, self._icon, self._type = sensor
|
||||
self.data = data
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return '{} {}'.format(self._client_name, self._name)
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the device state attributes."""
|
||||
if self._type == 1 and self._state is not None:
|
||||
schedule = {
|
||||
TIME_FRAME1_BEGIN: None,
|
||||
TIME_FRAME1_END: None,
|
||||
TIME_FRAME2_BEGIN: None,
|
||||
TIME_FRAME2_END: None,
|
||||
TIME_FRAME3_BEGIN: None,
|
||||
TIME_FRAME3_END: None
|
||||
}
|
||||
time_frame = self._state.split(';')
|
||||
for index, item in enumerate(sorted(schedule.items())):
|
||||
if index < len(time_frame):
|
||||
parsed = datetime.datetime.strptime(
|
||||
time_frame[index], '%H:%M')
|
||||
parsed = parsed.replace(
|
||||
datetime.datetime.now().year,
|
||||
datetime.datetime.now().month,
|
||||
datetime.datetime.now().day)
|
||||
schedule[item[0]] = parsed.isoformat()
|
||||
return schedule
|
||||
return None
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Icon to use in the frontend, if any."""
|
||||
return self._icon
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit of measurement."""
|
||||
return self._unit_of_measurement
|
||||
|
||||
def update(self):
|
||||
"""Fetch new state data for the sensor."""
|
||||
try:
|
||||
self.data.update(self._name, self._type)
|
||||
if self._name not in self.data.value:
|
||||
return
|
||||
|
||||
self._state = self.data.value[self._name]
|
||||
except RuntimeError:
|
||||
_LOGGER.debug("EbusdData.update exception")
|
||||
Reference in new issue
Block a user