Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Config entry and various changes #91

Merged
merged 28 commits into from
Apr 26, 2021
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a4626ff
Config entry and various changes
And3rsL Mar 9, 2021
76f4bcf
Update packages to beta channel
And3rsL Mar 9, 2021
0f72ff1
Fixed Leftover
And3rsL Mar 9, 2021
a5e5c21
Translatons and LiveMap Camera!
And3rsL Mar 9, 2021
7246eab
add version to manifest and workflow to set it
edenhaus Mar 9, 2021
15e358f
subscribe to water events
edenhaus Mar 9, 2021
343a007
Merge pull request #89 from edenhaus/version
And3rsL Mar 10, 2021
4fd1baa
add german translations
edenhaus Mar 10, 2021
1285043
New repo link and readme update
And3rsL Mar 10, 2021
5c288ce
Merge branch 'beta' of https://github.com/And3rsL/Deebot-for-Home-Ass…
And3rsL Mar 10, 2021
4ce2227
remove removed field
edenhaus Mar 10, 2021
9fa0be5
add hassfest validation
edenhaus Mar 10, 2021
87038bb
Unload & warnings fix
And3rsL Mar 10, 2021
c8e3973
disable sensors as default
edenhaus Mar 10, 2021
ccc35e8
subscribe to the correct event for each sensor
edenhaus Mar 10, 2021
9253bc3
fix schedule_update_ha_state
edenhaus Mar 10, 2021
66e4c80
hass object is required for schedule_update_ha_state
edenhaus Mar 10, 2021
ed681e7
fix copy paste error
edenhaus Mar 10, 2021
fe3d150
Merge branch 'beta' into beta-mop
edenhaus Mar 10, 2021
a0d46a9
fix schedule_update_ha_state
edenhaus Mar 10, 2021
0c3098a
Merge pull request #93 from edenhaus/beta-mop
edenhaus Mar 10, 2021
c4b1cb4
add device info
edenhaus Mar 10, 2021
9042a44
remove camera_image
edenhaus Mar 10, 2021
8597c26
Add FWVersion and Model Name
And3rsL Mar 11, 2021
d08f71c
add event unsubscribe for vacuum
edenhaus Mar 11, 2021
03dc3cd
call setScheduleUpdates in separate Task to create the config entry q…
edenhaus Mar 11, 2021
467bf47
Update hacs.json
And3rsL Mar 23, 2021
09cf828
Merge branch 'master' into beta
And3rsL Apr 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions custom_components/deebot/sensor.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Support for Deebot Sensor."""
from typing import Optional
import logging
from typing import Optional

from deebotozmo import (
EcoVacsAPI,
COMPONENT_FILTER,
COMPONENT_SIDE_BRUSH,
COMPONENT_MAIN_BRUSH,
)
from homeassistant.const import STATE_UNKNOWN
from homeassistant.helpers.entity import Entity

from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -43,7 +44,6 @@ class DeebotBaseSensor(Entity):

def __init__(self, vacbot, device_id):
"""Initialize the Sensor."""

self._state = STATE_UNKNOWN
self._vacbot = vacbot
self._id = device_id
Expand Down Expand Up @@ -71,14 +71,17 @@ def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
return False

@property
def should_poll(self) -> bool:
return False


class DeebotLastCleanImageSensor(DeebotBaseSensor):
"""Deebot Sensor"""

def __init__(self, vacbot, device_id):
"""Initialize the Sensor."""
super(DeebotLastCleanImageSensor, self).__init__(vacbot, device_id)
self._vacbot.cleanLogsEvents.subscribe(lambda _: self.schedule_update_ha_state())

@property
def state(self):
Expand All @@ -91,14 +94,18 @@ def icon(self) -> Optional[str]:
"""Return the icon to use in the frontend, if any."""
return "mdi:image-search"

async def async_added_to_hass(self) -> None:
"""Set up the event listeners now that hass is ready."""
listener = self._vacbot.cleanLogsEvents.subscribe(lambda _: self.schedule_update_ha_state())
self.async_on_remove(self._vacbot.cleanLogsEvents.unsubscribe(listener))


class DeebotWaterLevelSensor(DeebotBaseSensor):
"""Deebot Sensor"""

def __init__(self, vacbot, device_id):
"""Initialize the Sensor."""
super(DeebotWaterLevelSensor, self).__init__(vacbot, device_id)
self._vacbot.waterEvents.subscribe(lambda _: self.schedule_update_ha_state())

@property
def state(self):
Expand All @@ -112,14 +119,18 @@ def icon(self) -> Optional[str]:
"""Return the icon to use in the frontend, if any."""
return "mdi:water"

async def async_added_to_hass(self) -> None:
"""Set up the event listeners now that hass is ready."""
listener = self._vacbot.waterEvents.subscribe(lambda _: self.schedule_update_ha_state())
self.async_on_remove(self._vacbot.cleanLogsEvents.unsubscribe(listener))


class DeebotComponentSensor(DeebotBaseSensor):
"""Deebot Sensor"""

def __init__(self, vacbot, device_id):
"""Initialize the Sensor."""
super(DeebotComponentSensor, self).__init__(vacbot, device_id)
self._vacbot.lifespanEvents.subscribe(lambda _: self.schedule_update_ha_state())

@property
def unit_of_measurement(self):
Expand All @@ -142,14 +153,18 @@ def icon(self) -> Optional[str]:
elif self._id == COMPONENT_FILTER:
return "mdi:air-filter"

async def async_added_to_hass(self) -> None:
"""Set up the event listeners now that hass is ready."""
listener = self._vacbot.lifespanEvents.subscribe(lambda _: self.schedule_update_ha_state())
self.async_on_remove(self._vacbot.cleanLogsEvents.unsubscribe(listener))


class DeebotStatsSensor(DeebotBaseSensor):
"""Deebot Sensor"""

def __init__(self, vacbot, device_id):
"""Initialize the Sensor."""
super(DeebotStatsSensor, self).__init__(vacbot, device_id)
self._vacbot.statsEvents.subscribe(lambda _: self.schedule_update_ha_state())

@property
def unit_of_measurement(self):
Expand Down Expand Up @@ -181,3 +196,8 @@ def icon(self) -> Optional[str]:
return "mdi:timer-outline"
elif self._id == "stats_type":
return "mdi:cog"

async def async_added_to_hass(self) -> None:
"""Set up the event listeners now that hass is ready."""
listener = self._vacbot.statsEvents.subscribe(lambda _: self.schedule_update_ha_state())
self.async_on_remove(self._vacbot.cleanLogsEvents.unsubscribe(listener))