Skip to content

Commit

Permalink
Merge pull request #491 from asantaga/dev
Browse files Browse the repository at this point in the history
v3.4.8
  • Loading branch information
msp1974 authored Sep 7, 2024
2 parents 2ef04c7 + 4ad44ef commit df8d0d1
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 166 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Wiser Home Assistant Integration v3.4.7
# Wiser Home Assistant Integration v3.4.8

[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](https://github.com/hacs/integration)
[![downloads](https://shields.io/github/downloads/asantaga/wiserHomeAssistantPlatform/latest/total?style=for-the-badge)](https://github.com/asantaga/wiserHomeAssistantPlatform)
Expand All @@ -23,8 +23,18 @@ For more information checkout the AMAZING community thread available on
- Added PowerTagE support
- Climate entity for controlling hot water with external tank temp sensor

## Installing

[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=asantaga&repository=wiserHomeAssistantPlatform&category=integration)

## Change log

- v3.4.8
- Fix deprecation warning no waiting on setups - [#485](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/485)
- Fix color mode issue - [#479](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/479)
- Added smoke alarm sensors - [#457](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/457)
- Fixed missing save layout button in zigbee card - [#488](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/488)

- v3.4.7
- Bump api to v1.5.14 to improve handling of hub connection errors
- Fix - improve handling of hub update failures - [#434](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/434)
Expand Down
5 changes: 1 addition & 4 deletions custom_components/wiser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry):
}

# Setup platforms
for platform in WISER_PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, platform)
)
await hass.config_entries.async_forward_entry_setups(config_entry, WISER_PLATFORMS)

# Setup websocket services for frontend cards
await async_register_websockets(hass, coordinator)
Expand Down
131 changes: 131 additions & 0 deletions custom_components/wiser/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
"""Binary sensors."""

import logging

from config.custom_components.wiser.helpers import (
get_device_name,
get_identifier,
get_unique_id,
)
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .const import DATA, DOMAIN, MANUFACTURER

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities):
"""Set up Wiser climate device."""
data = hass.data[DOMAIN][config_entry.entry_id][DATA] # Get Handler

binary_sensors = []

# Smoke alarm sensors
for device in data.wiserhub.devices.smokealarms.all:
binary_sensors.extend(
[
WiserSmokeAlarm(data, device.id, "Smoke Alarm"),
WiserHeatAlarm(data, device.id, "Heat Alarm"),
WiserTamperAlarm(data, device.id, "Tamper Alarm"),
WiserFaultWarning(data, device.id, "Fault Warning"),
WiserRemoteAlarm(data, device.id, "Remote Alarm"),
]
)

async_add_entities(binary_sensors, True)


class BaseBinarySensor(CoordinatorEntity, BinarySensorEntity):
"""Base binary sensor class."""

def __init__(self, coordinator, device_id=0, sensor_type="") -> None:
"""Initialize the sensor."""
super().__init__(coordinator)
self._data = coordinator
self._device = self._data.wiserhub.devices.get_by_id(device_id)
self._device_id = device_id
self._device_name = None
self._sensor_type = sensor_type
self._state = getattr(self._device, self._sensor_type.replace(" ", "_").lower())
_LOGGER.debug(
f"{self._data.wiserhub.system.name} {self.name} initalise" # noqa: E501
)

@callback
def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
_LOGGER.debug(f"{self.name} device update requested")
self._device = self._data.wiserhub.devices.get_by_id(self._device_id)
self._state = getattr(self._device, self._sensor_type.replace(" ", "_").lower())
self.async_write_ha_state()

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

@property
def name(self):
"""Return the name of the sensor."""
return f"{get_device_name(self._data, self._device_id)} {self._sensor_type}"

@property
def unique_id(self):
"""Return uniqueid."""
return get_unique_id(self._data, "sensor", self._sensor_type, self._device_id)

@property
def device_info(self):
"""Return device specific attributes."""
return {
"name": get_device_name(self._data, self._device_id),
"identifiers": {(DOMAIN, get_identifier(self._data, self._device_id))},
"manufacturer": MANUFACTURER,
"model": self._data.wiserhub.system.product_type,
"sw_version": self._data.wiserhub.system.firmware_version,
"via_device": (DOMAIN, self._data.wiserhub.system.name),
}


class WiserSmokeAlarm(BaseBinarySensor):
"""Smoke Alarm sensor."""

_attr_device_class = BinarySensorDeviceClass.SMOKE

@property
def extra_state_attributes(self):
"""Return the state attributes of the battery."""
attrs = {}
attrs["led_brightness"] = self._device.led_brightness
attrs["alarm_sound_mode"] = self._device.alarm_sound_mode
attrs["alarm_sound_level"] = self._device.alarm_sound_level
attrs["life_time"] = self._device.life_time
attrs["hush_duration"] = self._device.hush_duration
return attrs


class WiserHeatAlarm(BaseBinarySensor):
"""Smoke Alarm sensor."""

_attr_device_class = BinarySensorDeviceClass.HEAT


class WiserTamperAlarm(BaseBinarySensor):
"""Smoke Alarm sensor."""

_attr_device_class = BinarySensorDeviceClass.TAMPER


class WiserFaultWarning(BaseBinarySensor):
"""Smoke Alarm sensor."""

_attr_device_class = BinarySensorDeviceClass.PROBLEM


class WiserRemoteAlarm(BaseBinarySensor):
"""Smoke Alarm sensor."""
6 changes: 4 additions & 2 deletions custom_components/wiser/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[email protected]
"""
VERSION = "3.4.7"

VERSION = "3.4.8"
DOMAIN = "wiser"
DATA_WISER_CONFIG = "wiser_config"
URL_BASE = "/wiser"
Expand All @@ -19,11 +20,12 @@
{
"name": "Wiser Zigbee Card",
"filename": "wiser-zigbee-card.js",
"version": "2.1.1",
"version": "2.1.2",
},
]

WISER_PLATFORMS = [
"binary_sensor",
"climate",
"sensor",
"switch",
Expand Down
4 changes: 2 additions & 2 deletions custom_components/wiser/device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from .events import WISER_EVENTS, WISER_EVENT

DEVICE = "device"
SUPPORTED_DOMAINS = set(event[CONF_DOMAIN] for event in WISER_EVENTS)
SUPPORTED_DOMAINS = {event[CONF_DOMAIN] for event in WISER_EVENTS}

TRIGGER_TYPES = set(event[CONF_TYPE] for event in WISER_EVENTS)
TRIGGER_TYPES = {event[CONF_TYPE] for event in WISER_EVENTS}

TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend(
{
Expand Down
346 changes: 192 additions & 154 deletions custom_components/wiser/frontend/wiser-zigbee-card.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion custom_components/wiser/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def supported_color_modes(self):
@property
def color_mode(self):
"""Return color mode."""
return {ColorMode.ONOFF}
return ColorMode.ONOFF

@property
def is_on(self):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/wiser/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"requirements": [
"aioWiserHeatAPI==1.5.14"
],
"version": "3.4.7",
"version": "3.4.8",
"zeroconf": [
{
"type": "_http._tcp.local.",
Expand Down
22 changes: 21 additions & 1 deletion custom_components/wiser/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie
if room.roomstat_id:
wiser_sensors.append(WiserLTSHumiditySensor(data, room.roomstat_id))

# Add temp sensors for smoke alarms
for device in data.wiserhub.devices.smokealarms.all:
wiser_sensors.append(
WiserLTSTempSensor(
data,
device.id,
sensor_type="smokealarm_temp",
)
)

# Add LTS sensors - for room Power and Energy for heating actuators
if data.wiserhub.devices.heating_actuators:
_LOGGER.debug("Setting up Heating Actuator LTS sensors")
Expand Down Expand Up @@ -825,6 +835,12 @@ def __init__(self, data, device_id, sensor_type="") -> None:
device_id,
f"LTS Floor Temperature {sensor_name}",
)
elif sensor_type == "smokealarm_temp":
super().__init__(
data,
device_id,
f"{data.wiserhub.devices.get_by_id(device_id).name} Temperature",
)
else:
super().__init__(
data,
Expand All @@ -844,6 +860,10 @@ def _handle_coordinator_update(self) -> None:
self._state = self._data.wiserhub.devices.get_by_id(
self._device_id
).floor_temperature_sensor.measured_temperature
elif self._lts_sensor_type == "smokealarm_temp":
self._state = self._data.wiserhub.devices.get_by_id(
self._device_id
).current_temperature
else:
if (
self._data.wiserhub.rooms.get_by_id(self._device_id).mode == "Off"
Expand All @@ -862,7 +882,7 @@ def _handle_coordinator_update(self) -> None:
@property
def device_info(self):
"""Return device specific attributes."""
if self._lts_sensor_type == "floor_current_temp":
if self._lts_sensor_type in ["floor_current_temp", "smokealarm_temp"]:
return {
"name": get_device_name(self._data, self._device_id),
"identifiers": {(DOMAIN, get_identifier(self._data, self._device_id))},
Expand Down

0 comments on commit df8d0d1

Please sign in to comment.