Add Intellifire cloud/local connectivity sensors (#127122)

This commit is contained in:
Jeef 2024-10-25 09:23:51 -06:00 committed by GitHub
parent 39a0c0d96e
commit 13ffe7acfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 148 additions and 20 deletions

View File

@ -5,8 +5,6 @@ from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
from intellifire4py.model import IntelliFirePollData
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
@ -26,7 +24,7 @@ from .entity import IntellifireEntity
class IntellifireBinarySensorRequiredKeysMixin:
"""Mixin for required keys."""
value_fn: Callable[[IntelliFirePollData], bool]
value_fn: Callable[[IntellifireDataUpdateCoordinator], bool | None]
@dataclass(frozen=True)
@ -40,100 +38,114 @@ INTELLIFIRE_BINARY_SENSORS: tuple[IntellifireBinarySensorEntityDescription, ...]
IntellifireBinarySensorEntityDescription(
key="on_off", # This is the sensor name
translation_key="flame", # This is the translation key
value_fn=lambda data: data.is_on,
value_fn=lambda coordinator: coordinator.data.is_on,
),
IntellifireBinarySensorEntityDescription(
key="timer_on",
translation_key="timer_on",
value_fn=lambda data: data.timer_on,
value_fn=lambda coordinator: coordinator.data.timer_on,
),
IntellifireBinarySensorEntityDescription(
key="pilot_light_on",
translation_key="pilot_light_on",
value_fn=lambda data: data.pilot_on,
value_fn=lambda coordinator: coordinator.data.pilot_on,
),
IntellifireBinarySensorEntityDescription(
key="thermostat_on",
translation_key="thermostat_on",
value_fn=lambda data: data.thermostat_on,
value_fn=lambda coordinator: coordinator.data.thermostat_on,
),
IntellifireBinarySensorEntityDescription(
key="error_pilot_flame",
translation_key="pilot_flame_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_pilot_flame,
value_fn=lambda coordinator: coordinator.data.error_pilot_flame,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="error_flame",
translation_key="flame_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_flame,
value_fn=lambda coordinator: coordinator.data.error_flame,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="error_fan_delay",
translation_key="fan_delay_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_fan_delay,
value_fn=lambda coordinator: coordinator.data.error_fan_delay,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="error_maintenance",
translation_key="maintenance_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_maintenance,
value_fn=lambda coordinator: coordinator.data.error_maintenance,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="error_disabled",
translation_key="disabled_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_disabled,
value_fn=lambda coordinator: coordinator.data.error_disabled,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="error_fan",
translation_key="fan_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_fan,
value_fn=lambda coordinator: coordinator.data.error_fan,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="error_lights",
translation_key="lights_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_lights,
value_fn=lambda coordinator: coordinator.data.error_lights,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="error_accessory",
translation_key="accessory_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_accessory,
value_fn=lambda coordinator: coordinator.data.error_accessory,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="error_soft_lock_out",
translation_key="soft_lock_out_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_soft_lock_out,
value_fn=lambda coordinator: coordinator.data.error_soft_lock_out,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="error_ecm_offline",
translation_key="ecm_offline_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_ecm_offline,
value_fn=lambda coordinator: coordinator.data.error_ecm_offline,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="error_offline",
translation_key="offline_error",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.error_offline,
value_fn=lambda coordinator: coordinator.data.error_offline,
device_class=BinarySensorDeviceClass.PROBLEM,
),
IntellifireBinarySensorEntityDescription(
key="local_connectivity",
translation_key="local_connectivity",
entity_category=EntityCategory.DIAGNOSTIC,
device_class=BinarySensorDeviceClass.CONNECTIVITY,
value_fn=lambda coordinator: coordinator.fireplace.local_connectivity,
),
IntellifireBinarySensorEntityDescription(
key="cloud_connectivity",
translation_key="cloud_connectivity",
entity_category=EntityCategory.DIAGNOSTIC,
device_class=BinarySensorDeviceClass.CONNECTIVITY,
value_fn=lambda coordinator: coordinator.fireplace.cloud_connectivity,
),
)
@ -157,6 +169,6 @@ class IntellifireBinarySensor(IntellifireEntity, BinarySensorEntity):
entity_description: IntellifireBinarySensorEntityDescription
@property
def is_on(self) -> bool:
def is_on(self) -> bool | None:
"""Use this to get the correct value."""
return self.entity_description.value_fn(self.coordinator.read_api.data)
return self.entity_description.value_fn(self.coordinator)

View File

@ -18,6 +18,20 @@
},
"fan_error": {
"default": "mdi:fan-alert"
},
"local_connectivity": {
"default": "mdi:lan-pending",
"state": {
"on": "mdi:lan-connect",
"off": "mdi:lan-disconnect"
}
},
"cloud_connectivity": {
"default": "mdi:cloud-question",
"state": {
"on": "mdi:cloud-check-variant-outline",
"off": "mdi:cloud-alert-outline"
}
}
},
"number": {

View File

@ -73,6 +73,12 @@
},
"offline_error": {
"name": "Offline error"
},
"cloud_connectivity": {
"name": "Cloud connectivity"
},
"local_connectivity": {
"name": "Local connectivity"
}
},
"fan": {

View File

@ -47,6 +47,54 @@
'state': 'off',
})
# ---
# name: test_all_binary_sensor_entities[binary_sensor.intellifire_cloud_connectivity-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.intellifire_cloud_connectivity',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.CONNECTIVITY: 'connectivity'>,
'original_icon': None,
'original_name': 'Cloud connectivity',
'platform': 'intellifire',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'cloud_connectivity',
'unique_id': 'cloud_connectivity_mock_serial',
'unit_of_measurement': None,
})
# ---
# name: test_all_binary_sensor_entities[binary_sensor.intellifire_cloud_connectivity-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by unpublished Intellifire API',
'device_class': 'connectivity',
'friendly_name': 'IntelliFire Cloud connectivity',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.intellifire_cloud_connectivity',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_all_binary_sensor_entities[binary_sensor.intellifire_disabled_error-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
@ -382,6 +430,54 @@
'state': 'off',
})
# ---
# name: test_all_binary_sensor_entities[binary_sensor.intellifire_local_connectivity-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.intellifire_local_connectivity',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.CONNECTIVITY: 'connectivity'>,
'original_icon': None,
'original_name': 'Local connectivity',
'platform': 'intellifire',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'local_connectivity',
'unique_id': 'local_connectivity_mock_serial',
'unit_of_measurement': None,
})
# ---
# name: test_all_binary_sensor_entities[binary_sensor.intellifire_local_connectivity-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by unpublished Intellifire API',
'device_class': 'connectivity',
'friendly_name': 'IntelliFire Local connectivity',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.intellifire_local_connectivity',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_binary_sensor_entities[binary_sensor.intellifire_maintenance_error-entry]
EntityRegistryEntrySnapshot({
'aliases': set({