From 71a27b7d671a34452d2a8fa06012e3296cbf8e60 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Thu, 4 Jul 2019 22:51:04 +0200 Subject: [PATCH] Added pool pump --- config_creation/fhem.yaml | 10 ++++++++-- custom_components/fhem/sensor.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config_creation/fhem.yaml b/config_creation/fhem.yaml index 08065db..4c066c7 100644 --- a/config_creation/fhem.yaml +++ b/config_creation/fhem.yaml @@ -75,13 +75,14 @@ switch: - name: Bad Lüfter fhem_ids: - Bad_Luefter - +- name: Pool Pumpe + fhem_ids: + - SteckdosenSchalter_Sw # ------------------------------ Motion Sensors ------------------------------------ binary_sensor: - - name: Arbeitszimmer Martin Bewegungsmelder Batterie fhem_ids: - ArbeitszimmerMartin_Bewegungsmelder @@ -91,8 +92,13 @@ binary_sensor: - ArbeitszimmerMartin_Bewegungsmelder fhem_sensor_type: motion + sensor: - name: Arbeitszimmer Martin Bewegungsmelder Helligkeit fhem_ids: - ArbeitszimmerMartin_Bewegungsmelder fhem_sensor_type: brightness +- name: Pool Pumpe Verbrauch + fhem_sensor_type: power + fhem_ids: + - SteckdosenSchalter_Pwr diff --git a/custom_components/fhem/sensor.py b/custom_components/fhem/sensor.py index f4d433e..9c92d2d 100644 --- a/custom_components/fhem/sensor.py +++ b/custom_components/fhem/sensor.py @@ -16,7 +16,7 @@ _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_FHEM_IDS): vol.All(cv.ensure_list, [cv.string]), vol.Required(CONF_NAME): cv.string, - vol.Optional(CONF_FHEM_SENSOR_TYPE, default='brightness'): vol.In(('brightness',)), + vol.Optional(CONF_FHEM_SENSOR_TYPE, default='brightness'): vol.In(('brightness', 'power')), }) @@ -42,7 +42,6 @@ class FhemSensor(Entity): self._type = sensor_type self._available = True self._state = None - self._unsubscribe_motion_off = None @property def name(self): @@ -67,6 +66,11 @@ class FhemSensor(Entity): _, new_value = line.split(':') self._state = int(float(new_value) / 255 * 100) await self.async_update_ha_state() + elif self._type == 'power': + self._available = True + _, new_value = line + self._state = int(new_value) + await self.async_update_ha_state() elif line.startswith('ResndFail') or line.startswith('MISSING ACK'): self._available = False await self.async_update_ha_state() @@ -81,3 +85,5 @@ class FhemSensor(Entity): def unit_of_measurement(self): if self._type == 'brightness': return '%' + elif self._type == 'power': + return 'W'