Skip to content

Commit

Permalink
Add sensors for Yandex socket
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Jan 15, 2024
1 parent 335a4c6 commit f08f150
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/yandex_station/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

_LOGGER = logging.getLogger(__name__)

INCLUDE_TYPES = ["devices.types.sensor"]
INCLUDE_TYPES = ["devices.types.sensor", "devices.types.socket"]
INCLUDE_PROPERTIES = ["devices.properties.float", "devices.properties.event"]

SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
Expand Down
75 changes: 74 additions & 1 deletion tests/test_switch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from custom_components.yandex_station.switch import YandexSwitch
from . import true, false, update_ha_state
from . import true, false, null, update_ha_state


def test_switch():
Expand Down Expand Up @@ -32,6 +32,79 @@ def test_switch():
assert state.attributes == {"friendly_name": "Выключатель"}


def test_socket_yandex():
device = {
"id": "xxx",
"name": "Белая розетка",
"type": "devices.types.socket",
"icon_url": "https://avatars.mds.yandex.net/get-iot/icons-devices-devices.types.socket.svg/orig",
"capabilities": [
{
"reportable": true,
"retrievable": true,
"type": "devices.capabilities.on_off",
"state": {"instance": "on", "value": true},
"parameters": {"split": false},
}
],
"properties": [
{
"type": "devices.properties.float",
"retrievable": true,
"reportable": true,
"parameters": {
"instance": "voltage",
"name": "текущее напряжение",
"unit": "unit.volt",
},
"state": {"percent": null, "status": null, "value": 227},
"state_changed_at": "2024-01-14T12:08:46Z",
"last_updated": "2024-01-14T12:09:44Z",
},
{
"type": "devices.properties.float",
"retrievable": true,
"reportable": true,
"parameters": {
"instance": "power",
"name": "потребляемая мощность",
"unit": "unit.watt",
},
"state": {"percent": null, "status": null, "value": 0},
"state_changed_at": "2024-01-11T05:00:58Z",
"last_updated": "2024-01-14T12:09:44Z",
},
{
"type": "devices.properties.float",
"retrievable": true,
"reportable": true,
"parameters": {
"instance": "amperage",
"name": "потребление тока",
"unit": "unit.ampere",
},
"state": {"percent": null, "status": null, "value": 0},
"state_changed_at": "2024-01-11T05:00:58Z",
"last_updated": "2024-01-14T12:09:44Z",
},
],
"item_type": "device",
"skill_id": "T",
"room_name": "Детская",
"state": "online",
"render_info": {"icon": {"id": "yandex.socket"}},
"created": "2022-11-16T18:08:19Z",
"parameters": {
"device_info": {
"manufacturer": "Yandex",
"model": "YNDX-0007",
"hw_version": "1.0",
"sw_version": "1.0.4",
}
},
}


def test_washing_machine():
device = {
"id": "xxx",
Expand Down

0 comments on commit f08f150

Please sign in to comment.