mirror of
https://github.com/home-assistant/core.git
synced 2025-11-10 11:29:46 +00:00
* Shelly RPC sub-devices
* Better varaible name
* Add get_rpc_device_info helper
* Revert channel name changes
* Use get_rpc_device_info
* Add get_rpc_device_info helper
* Use get_block_device_info
* Use helpers in the button platform
* Fix channel name and roller mode for block devices
* Fix EM3 gen1
* Fix channel name for RPC devices
* Revert test changes
* Fix/improve test_block_get_block_channel_name
* Fix test_get_rpc_channel_name_multiple_components
* Fix tests
* Fix tests
* Fix tests
* Use key instead of index to generate sub-device identifier
* Improve logic for Pro RGBWW PM
* Split channels for em1
* Better channel name
* Cleaning
* has_entity_name is True
* Add get_block_sub_device_name() function
* Improve block functions
* Add get_rpc_sub_device_name() function
* Remove _attr_name
* Remove name for button with device class
* Fix names of virtual components
* Better Input name
* Fix get_rpc_channel_name()
* Fix names for Inputs
* get_rpc_channel_name() improvement
* Better variable name
* Clean RPC functions
* Fix input_name type
* Fix test
* Fix entity_ids for Blu Trv
* Fix get_block_channel_name()
* Fix for Blu Trv, once again
* Revert name for reboot button
* Fix button tests
* Fix tests
* Fix coordinator tests
* Fix tests for cover platform
* Fix tests for event platform
* Fix entity_ids in init tests
* Fix get_block_channel_name() for lights
* Fix tests for light platform
* Fix test for logbook
* Update snapshots for number platform
* Fix tests for sensor platform
* Fix tests for switch platform
* Fix tests for utils
* Uncomment
* Fix tests for flood
* Fix Valve entity name
* Fix climate tests
* Fix test for diagnostics
* Fix tests for init
* Remove old snapshots
* Add tests for 2PM Gen3
* Add comment
* More tests
* Cleaning
* Clean fixtures
* Update tests
* Anonymize coordinates in fixtures
* Split Pro 3EM entities into sub-devices
* Make sub-device names more unique
* 3EM (gen1) does not support sub-devices
* Coverage
* Rename "device temperature" sensor to the "relay temperature"
* Update tests after rebase
* Support sub-devices for 3EM (gen1)
* Mark has-entity-name rule as done 🎉
* Rename `relay temperature` to `temperature`
120 lines
3.6 KiB
Python
120 lines
3.6 KiB
Python
"""The tests for Shelly logbook."""
|
|
|
|
from unittest.mock import Mock
|
|
|
|
from homeassistant.components.shelly.const import (
|
|
ATTR_CHANNEL,
|
|
ATTR_CLICK_TYPE,
|
|
ATTR_DEVICE,
|
|
DOMAIN,
|
|
EVENT_SHELLY_CLICK,
|
|
)
|
|
from homeassistant.const import ATTR_DEVICE_ID
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import device_registry as dr
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
from . import init_integration
|
|
|
|
from tests.components.logbook.common import MockRow, mock_humanify
|
|
|
|
|
|
async def test_humanify_shelly_click_event_block_device(
|
|
hass: HomeAssistant, device_registry: dr.DeviceRegistry, mock_block_device: Mock
|
|
) -> None:
|
|
"""Test humanifying Shelly click event for block device."""
|
|
entry = await init_integration(hass, 1)
|
|
device = dr.async_entries_for_config_entry(device_registry, entry.entry_id)[0]
|
|
|
|
hass.config.components.add("recorder")
|
|
assert await async_setup_component(hass, "logbook", {})
|
|
await hass.async_block_till_done()
|
|
|
|
event1, event2 = mock_humanify(
|
|
hass,
|
|
[
|
|
MockRow(
|
|
EVENT_SHELLY_CLICK,
|
|
{
|
|
ATTR_DEVICE_ID: device.id,
|
|
ATTR_DEVICE: "shellyix3-12345678",
|
|
ATTR_CLICK_TYPE: "single",
|
|
ATTR_CHANNEL: 1,
|
|
},
|
|
),
|
|
MockRow(
|
|
EVENT_SHELLY_CLICK,
|
|
{
|
|
ATTR_DEVICE_ID: "no_device_id",
|
|
ATTR_DEVICE: "shellyswitch25-12345678",
|
|
ATTR_CLICK_TYPE: "long",
|
|
ATTR_CHANNEL: 2,
|
|
},
|
|
),
|
|
],
|
|
)
|
|
|
|
assert event1["name"] == "Shelly"
|
|
assert event1["domain"] == DOMAIN
|
|
assert (
|
|
event1["message"]
|
|
== "'single' click event for Test name channel 1 Input was fired"
|
|
)
|
|
|
|
assert event2["name"] == "Shelly"
|
|
assert event2["domain"] == DOMAIN
|
|
assert (
|
|
event2["message"]
|
|
== "'long' click event for shellyswitch25-12345678 channel 2 Input was fired"
|
|
)
|
|
|
|
|
|
async def test_humanify_shelly_click_event_rpc_device(
|
|
hass: HomeAssistant, device_registry: dr.DeviceRegistry, mock_rpc_device: Mock
|
|
) -> None:
|
|
"""Test humanifying Shelly click event for rpc device."""
|
|
entry = await init_integration(hass, 2)
|
|
device = dr.async_entries_for_config_entry(device_registry, entry.entry_id)[0]
|
|
|
|
hass.config.components.add("recorder")
|
|
assert await async_setup_component(hass, "logbook", {})
|
|
await hass.async_block_till_done()
|
|
|
|
event1, event2 = mock_humanify(
|
|
hass,
|
|
[
|
|
MockRow(
|
|
EVENT_SHELLY_CLICK,
|
|
{
|
|
ATTR_DEVICE_ID: device.id,
|
|
ATTR_DEVICE: "shellyplus1pm-12345678",
|
|
ATTR_CLICK_TYPE: "single_push",
|
|
ATTR_CHANNEL: 1,
|
|
},
|
|
),
|
|
MockRow(
|
|
EVENT_SHELLY_CLICK,
|
|
{
|
|
ATTR_DEVICE_ID: "no_device_id",
|
|
ATTR_DEVICE: "shellypro4pm-12345678",
|
|
ATTR_CLICK_TYPE: "btn_down",
|
|
ATTR_CHANNEL: 2,
|
|
},
|
|
),
|
|
],
|
|
)
|
|
|
|
assert event1["name"] == "Shelly"
|
|
assert event1["domain"] == DOMAIN
|
|
assert (
|
|
event1["message"]
|
|
== "'single_push' click event for Test name Test input 0 Input was fired"
|
|
)
|
|
|
|
assert event2["name"] == "Shelly"
|
|
assert event2["domain"] == DOMAIN
|
|
assert (
|
|
event2["message"]
|
|
== "'btn_down' click event for shellypro4pm-12345678 channel 2 Input was fired"
|
|
)
|