mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Add Homee binary sensor platform (#140088)
* binary-sensor initial * Add binary sensor tests * small string changes * fix review comments * review change 1
This commit is contained in:
parent
1ee4f02e70
commit
42f0e70cde
@ -15,6 +15,7 @@ from .const import DOMAIN
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.BUTTON,
|
||||
Platform.COVER,
|
||||
Platform.LIGHT,
|
||||
|
190
homeassistant/components/homee/binary_sensor.py
Normal file
190
homeassistant/components/homee/binary_sensor.py
Normal file
@ -0,0 +1,190 @@
|
||||
"""The Homee binary sensor platform."""
|
||||
|
||||
from pyHomee.const import AttributeType
|
||||
from pyHomee.model import HomeeAttribute
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.const import EntityCategory
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import HomeeConfigEntry
|
||||
from .entity import HomeeEntity
|
||||
|
||||
PARALLEL_UPDATES = 0
|
||||
|
||||
BINARY_SENSOR_DESCRIPTIONS: dict[AttributeType, BinarySensorEntityDescription] = {
|
||||
AttributeType.BATTERY_LOW_ALARM: BinarySensorEntityDescription(
|
||||
key="battery",
|
||||
device_class=BinarySensorDeviceClass.BATTERY,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.BLACKOUT_ALARM: BinarySensorEntityDescription(
|
||||
key="blackout_alarm",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.COALARM: BinarySensorEntityDescription(
|
||||
key="carbon_monoxide", device_class=BinarySensorDeviceClass.CO
|
||||
),
|
||||
AttributeType.CO2ALARM: BinarySensorEntityDescription(
|
||||
key="carbon_dioxide", device_class=BinarySensorDeviceClass.PROBLEM
|
||||
),
|
||||
AttributeType.FLOOD_ALARM: BinarySensorEntityDescription(
|
||||
key="flood",
|
||||
device_class=BinarySensorDeviceClass.MOISTURE,
|
||||
),
|
||||
AttributeType.HIGH_TEMPERATURE_ALARM: BinarySensorEntityDescription(
|
||||
key="high_temperature",
|
||||
device_class=BinarySensorDeviceClass.HEAT,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.LEAK_ALARM: BinarySensorEntityDescription(
|
||||
key="leak_alarm",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
),
|
||||
AttributeType.LOAD_ALARM: BinarySensorEntityDescription(
|
||||
key="load_alarm",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.LOCK_STATE: BinarySensorEntityDescription(
|
||||
key="lock",
|
||||
device_class=BinarySensorDeviceClass.LOCK,
|
||||
),
|
||||
AttributeType.LOW_TEMPERATURE_ALARM: BinarySensorEntityDescription(
|
||||
key="low_temperature",
|
||||
device_class=BinarySensorDeviceClass.COLD,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.MALFUNCTION_ALARM: BinarySensorEntityDescription(
|
||||
key="malfunction",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.MAXIMUM_ALARM: BinarySensorEntityDescription(
|
||||
key="maximum",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.MINIMUM_ALARM: BinarySensorEntityDescription(
|
||||
key="minimum",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.MOTION_ALARM: BinarySensorEntityDescription(
|
||||
key="motion",
|
||||
device_class=BinarySensorDeviceClass.MOTION,
|
||||
),
|
||||
AttributeType.MOTOR_BLOCKED_ALARM: BinarySensorEntityDescription(
|
||||
key="motor_blocked",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.ON_OFF: BinarySensorEntityDescription(
|
||||
key="plug",
|
||||
device_class=BinarySensorDeviceClass.PLUG,
|
||||
),
|
||||
AttributeType.OPEN_CLOSE: BinarySensorEntityDescription(
|
||||
key="opening",
|
||||
device_class=BinarySensorDeviceClass.OPENING,
|
||||
),
|
||||
AttributeType.OVER_CURRENT_ALARM: BinarySensorEntityDescription(
|
||||
key="overcurrent",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.OVERLOAD_ALARM: BinarySensorEntityDescription(
|
||||
key="overload",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.PRESENCE_ALARM: BinarySensorEntityDescription(
|
||||
key="presence",
|
||||
device_class=BinarySensorDeviceClass.PRESENCE,
|
||||
),
|
||||
AttributeType.POWER_SUPPLY_ALARM: BinarySensorEntityDescription(
|
||||
key="power",
|
||||
device_class=BinarySensorDeviceClass.POWER,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.RAIN_FALL: BinarySensorEntityDescription(
|
||||
key="rain",
|
||||
device_class=BinarySensorDeviceClass.MOISTURE,
|
||||
),
|
||||
AttributeType.REPLACE_FILTER_ALARM: BinarySensorEntityDescription(
|
||||
key="replace_filter",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.SMOKE_ALARM: BinarySensorEntityDescription(
|
||||
key="smoke",
|
||||
device_class=BinarySensorDeviceClass.SMOKE,
|
||||
),
|
||||
AttributeType.STORAGE_ALARM: BinarySensorEntityDescription(
|
||||
key="storage",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.SURGE_ALARM: BinarySensorEntityDescription(
|
||||
key="surge",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.TAMPER_ALARM: BinarySensorEntityDescription(
|
||||
key="tamper",
|
||||
device_class=BinarySensorDeviceClass.TAMPER,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.VOLTAGE_DROP_ALARM: BinarySensorEntityDescription(
|
||||
key="voltage_drop",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
AttributeType.WATER_ALARM: BinarySensorEntityDescription(
|
||||
key="water",
|
||||
device_class=BinarySensorDeviceClass.MOISTURE,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: HomeeConfigEntry,
|
||||
async_add_devices: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Add the Homee platform for the binary sensor component."""
|
||||
|
||||
async_add_devices(
|
||||
HomeeBinarySensor(
|
||||
attribute, config_entry, BINARY_SENSOR_DESCRIPTIONS[attribute.type]
|
||||
)
|
||||
for node in config_entry.runtime_data.nodes
|
||||
for attribute in node.attributes
|
||||
if attribute.type in BINARY_SENSOR_DESCRIPTIONS and not attribute.editable
|
||||
)
|
||||
|
||||
|
||||
class HomeeBinarySensor(HomeeEntity, BinarySensorEntity):
|
||||
"""Representation of a Homee binary sensor."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
attribute: HomeeAttribute,
|
||||
entry: HomeeConfigEntry,
|
||||
description: BinarySensorEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize a Homee binary sensor entity."""
|
||||
super().__init__(attribute, entry)
|
||||
|
||||
self.entity_description = description
|
||||
self._attr_translation_key = description.key
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if the binary sensor is on."""
|
||||
return bool(self._attribute.current_value)
|
@ -26,6 +26,76 @@
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"blackout_alarm": {
|
||||
"name": "Blackout"
|
||||
},
|
||||
"carbon_dioxide": {
|
||||
"name": "Carbon dioxide"
|
||||
},
|
||||
"flood": {
|
||||
"name": "Flood"
|
||||
},
|
||||
"high_temperature": {
|
||||
"name": "High temperature"
|
||||
},
|
||||
"leak_alarm": {
|
||||
"name": "Leak"
|
||||
},
|
||||
"load_alarm": {
|
||||
"name": "Load",
|
||||
"state": {
|
||||
"off": "Normal",
|
||||
"on": "Overload"
|
||||
}
|
||||
},
|
||||
"low_temperature": {
|
||||
"name": "Low temperature"
|
||||
},
|
||||
"malfunction": {
|
||||
"name": "Malfunction"
|
||||
},
|
||||
"maximum": {
|
||||
"name": "Maximumn level"
|
||||
},
|
||||
"minimum": {
|
||||
"name": "Minumum level"
|
||||
},
|
||||
"motor_blocked": {
|
||||
"name": "Motor blocked"
|
||||
},
|
||||
"overcurrent": {
|
||||
"name": "Overcurrent"
|
||||
},
|
||||
"overload": {
|
||||
"name": "Overload"
|
||||
},
|
||||
"rain": {
|
||||
"name": "Rain"
|
||||
},
|
||||
"replace_filter": {
|
||||
"name": "Replace filter",
|
||||
"state": {
|
||||
"on": "Replace"
|
||||
}
|
||||
},
|
||||
"storage": {
|
||||
"name": "Storage",
|
||||
"state": {
|
||||
"off": "Space available",
|
||||
"on": "Storage full"
|
||||
}
|
||||
},
|
||||
"surge": {
|
||||
"name": "Surge"
|
||||
},
|
||||
"voltage_drop": {
|
||||
"name": "Voltage drop"
|
||||
},
|
||||
"water": {
|
||||
"name": "Water"
|
||||
}
|
||||
},
|
||||
"button": {
|
||||
"automatic_mode": {
|
||||
"name": "Automatic mode"
|
||||
|
891
tests/components/homee/fixtures/binary_sensors.json
Normal file
891
tests/components/homee/fixtures/binary_sensors.json
Normal file
@ -0,0 +1,891 @@
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Test Binary Sensor",
|
||||
"profile": 4026,
|
||||
"image": "default",
|
||||
"favorite": 0,
|
||||
"order": 20,
|
||||
"protocol": 1,
|
||||
"routing": 0,
|
||||
"state": 1,
|
||||
"state_changed": 1709379826,
|
||||
"added": 1676199446,
|
||||
"history": 1,
|
||||
"cube_type": 1,
|
||||
"note": "",
|
||||
"services": 5,
|
||||
"phonetic_name": "",
|
||||
"owner": 2,
|
||||
"security": 0,
|
||||
"attributes": [
|
||||
{
|
||||
"id": 1,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 69,
|
||||
"state": 1,
|
||||
"last_changed": 1706461181,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 17,
|
||||
"state": 1,
|
||||
"last_changed": 1691668428,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 132,
|
||||
"state": 1,
|
||||
"last_changed": 1691668428,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 1.0,
|
||||
"target_value": 1.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 228,
|
||||
"state": 1,
|
||||
"last_changed": 1691668428,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 1.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 12,
|
||||
"state": 1,
|
||||
"last_changed": 1699456267,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 52,
|
||||
"state": 1,
|
||||
"last_changed": 1694176210,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 68,
|
||||
"state": 1,
|
||||
"last_changed": 1694176210,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 1.0,
|
||||
"target_value": 1.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 139,
|
||||
"state": 1,
|
||||
"last_changed": 1650402359,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 1.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 232,
|
||||
"state": 1,
|
||||
"last_changed": 1711897362,
|
||||
"changed_by": 4,
|
||||
"changed_by_id": 5,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 35,
|
||||
"week": 5,
|
||||
"month": 1,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 1.0,
|
||||
"target_value": 1.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 54,
|
||||
"state": 1,
|
||||
"last_changed": 1650402359,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 70,
|
||||
"state": 1,
|
||||
"last_changed": 1738231378,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 4,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 78,
|
||||
"state": 1,
|
||||
"last_changed": 1738231378,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 4,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 77,
|
||||
"state": 1,
|
||||
"last_changed": 1735964135,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 1.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 25,
|
||||
"state": 1,
|
||||
"last_changed": 1709933563,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 35,
|
||||
"week": 5,
|
||||
"month": 1,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 1.0,
|
||||
"target_value": 1.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 330,
|
||||
"state": 1,
|
||||
"last_changed": 1709933563,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 35,
|
||||
"week": 5,
|
||||
"month": 1,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"node_id": 1,
|
||||
"instance": 2,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 1,
|
||||
"state": 1,
|
||||
"last_changed": 1694024544,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"can_observe": [300],
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 35,
|
||||
"week": 5,
|
||||
"month": 1,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 14,
|
||||
"state": 1,
|
||||
"last_changed": 1739320320,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"history": {
|
||||
"day": 35,
|
||||
"week": 5,
|
||||
"month": 1,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 143,
|
||||
"state": 1,
|
||||
"last_changed": 1694992768,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 140,
|
||||
"state": 1,
|
||||
"last_changed": 1718900928,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 76,
|
||||
"state": 1,
|
||||
"last_changed": 1718900928,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 182,
|
||||
"state": 1,
|
||||
"last_changed": 1718900928,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 22,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 101,
|
||||
"state": 1,
|
||||
"last_changed": 1700056646,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"history": {
|
||||
"day": 35,
|
||||
"week": 5,
|
||||
"month": 1,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 23,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "n%2Fa",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 289,
|
||||
"state": 1,
|
||||
"last_changed": 1736106312,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 2,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 1.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 16,
|
||||
"state": 1,
|
||||
"last_changed": 1616314530,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 25,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 2,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 1.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 181,
|
||||
"state": 1,
|
||||
"last_changed": 1616314530,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 26,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 138,
|
||||
"state": 1,
|
||||
"last_changed": 1700747644,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 27,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 30,
|
||||
"state": 1,
|
||||
"last_changed": 1709933563,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 28,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 141,
|
||||
"state": 1,
|
||||
"last_changed": 1700747644,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 29,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 0,
|
||||
"type": 80,
|
||||
"state": 1,
|
||||
"last_changed": 1700747644,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": "",
|
||||
"options": {
|
||||
"automations": ["reset"],
|
||||
"history": {
|
||||
"day": 182,
|
||||
"week": 26,
|
||||
"month": 6,
|
||||
"stepped": true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
1392
tests/components/homee/snapshots/test_binary_sensor.ambr
Normal file
1392
tests/components/homee/snapshots/test_binary_sensor.ambr
Normal file
File diff suppressed because it is too large
Load Diff
29
tests/components/homee/test_binary_sensor.py
Normal file
29
tests/components/homee/test_binary_sensor.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""Test homee binary sensors."""
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import build_mock_node, setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
|
||||
async def test_sensor_snapshot(
|
||||
hass: HomeAssistant,
|
||||
mock_homee: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test the multisensor snapshot."""
|
||||
mock_homee.nodes = [build_mock_node("binary_sensors.json")]
|
||||
mock_homee.get_node_by_id.return_value = mock_homee.nodes[0]
|
||||
with patch("homeassistant.components.homee.PLATFORMS", [Platform.BINARY_SENSOR]):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
Loading…
x
Reference in New Issue
Block a user