Compare commits

...

3 Commits

Author SHA1 Message Date
Necroneco
7a04177d43
Merge 1dc376887f into e174a73f52 2025-03-24 16:38:08 +08:00
dw881114
e174a73f52
Update spec_modify.yaml (#921)
Some checks are pending
Tests / check-rule-format (push) Waiting to run
Validate / validate-hassfest (push) Waiting to run
Validate / validate-hacs (push) Waiting to run
Validate / validate-lint (push) Waiting to run
Validate / validate-setup (push) Waiting to run
2025-03-24 16:34:48 +08:00
caibinqing
1dc376887f
feat: make submersion-state, contact-state, occupancy-status as binary_sensor 2025-03-18 23:38:17 +08:00
3 changed files with 37 additions and 16 deletions

View File

@ -89,4 +89,8 @@ class BinarySensor(MIoTPropertyEntity, BinarySensorEntity):
@property @property
def is_on(self) -> bool: def is_on(self) -> bool:
"""On/Off state. True if the binary sensor is on, False otherwise.""" """On/Off state. True if the binary sensor is on, False otherwise."""
if self.spec.name == 'contact-state':
return self._value is False
elif self.spec.name == 'occupancy-status':
return bool(self._value)
return self._value is True return self._value is True

View File

@ -85,37 +85,37 @@ urn:miot-spec-v2:device:thermostat:0000A031:suittc-wk168:1:
prop.2.3: prop.2.3:
value-list: value-list:
- value: 1 - value: 1
description: one description: '1'
- value: 2 - value: 2
description: two description: '2'
- value: 3 - value: 3
description: three description: '3'
- value: 4 - value: 4
description: four description: '4'
- value: 5 - value: 5
description: five description: '5'
- value: 6 - value: 6
description: six description: '6'
- value: 7 - value: 7
description: seven description: '7'
- value: 8 - value: 8
description: eight description: '8'
- value: 9 - value: 9
description: nine description: '9'
- value: 10 - value: 10
description: ten description: '10'
- value: 11 - value: 11
description: eleven description: '11'
- value: 12 - value: 12
description: twelve description: '12'
- value: 13 - value: 13
description: thirteen description: '13'
- value: 14 - value: 14
description: fourteen description: '14'
- value: 15 - value: 15
description: fifteen description: '15'
- value: 16 - value: 16
description: sixteen description: '16'
urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:3: urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:3:
prop.5.1: prop.5.1:
expr: round(src_value*6/1000000, 3) expr: round(src_value*6/1000000, 3)

View File

@ -48,6 +48,7 @@ Conversion rules of MIoT-Spec-V2 instance to Home Assistant entity.
from homeassistant.components.sensor import SensorDeviceClass from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.components.sensor import SensorStateClass from homeassistant.components.sensor import SensorStateClass
from homeassistant.components.event import EventDeviceClass from homeassistant.components.event import EventDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
@ -454,12 +455,28 @@ SPEC_PROP_TRANS_MAP: dict = {
'format': {'int', 'float'}, 'format': {'int', 'float'},
'access': {'read'} 'access': {'read'}
}, },
'binary_sensor': {
'format': {'bool', 'int', 'float'},
'access': {'read'}
},
'switch': { 'switch': {
'format': {'bool'}, 'format': {'bool'},
'access': {'read', 'write'} 'access': {'read', 'write'}
} }
}, },
'properties': { 'properties': {
'submersion-state': {
'device_class': BinarySensorDeviceClass.MOISTURE,
'entity': 'binary_sensor'
},
'contact-state': {
'device_class': BinarySensorDeviceClass.DOOR,
'entity': 'binary_sensor'
},
'occupancy-status': {
'device_class': BinarySensorDeviceClass.OCCUPANCY,
'entity': 'binary_sensor',
},
'temperature': { 'temperature': {
'device_class': SensorDeviceClass.TEMPERATURE, 'device_class': SensorDeviceClass.TEMPERATURE,
'entity': 'sensor', 'entity': 'sensor',