mirror of
https://github.com/home-assistant/core.git
synced 2025-08-15 16:30:04 +00:00
.devcontainer
.github
.vscode
homeassistant
machine
pylint
rootfs
script
tests
auth
components
abode
accuweather
acmeda
adax
adguard
advantage_air
aemet
aftership
agent_dvr
air_quality
airly
airnow
airq
airthings
airthings_ble
airtouch4
airvisual
airvisual_pro
airzone
airzone_cloud
aladdin_connect
alarm_control_panel
alarmdecoder
alert
alexa
amberelectric
ambiclimate
ambient_station
analytics
android_ip_webcam
androidtv
androidtv_remote
anova
anthemav
aosmith
apache_kafka
apcupsd
api
api_streams
apple_tv
application_credentials
apprise
aprs
aranet
arcam_fmj
aseko_pool_live
assist_pipeline
asuswrt
atag
august
aurora
aurora_abb_powerone
aussie_broadband
auth
automation
awair
aws
axis
azure_devops
azure_event_hub
backup
baf
balboa
bayesian
binary_sensor
blackbird
blebox
blink
blue_current
bluemaestro
blueprint
bluetooth
bluetooth_adapters
bluetooth_le_tracker
bmw_connected_drive
bond
bosch_shc
braviatv
broadlink
brother
brottsplatskartan
brunt
bsblan
bthome
buienradar
button
caldav
calendar
camera
canary
cast
ccm15
cert_expiry
clicksend_tts
climate
cloud
cloudflare
co2signal
coinbase
color_extractor
comelit
comfoconnect
command_line
compensation
config
configurator
control4
conversation
coolmaster
counter
cover
cpuspeed
crownstone
daikin
datadog
date
datetime
debugpy
deconz
default_config
deluge
demo
denonavr
derivative
devialet
device_automation
device_sun_light_trigger
device_tracker
devolo_home_control
devolo_home_network
dexcom
dhcp
diagnostics
dialogflow
directv
discord
discovergy
dlink
dlna_dmr
dlna_dms
dnsip
doorbird
dormakaba_dkey
dremel_3d_printer
drop_connect
dsmr
dsmr_reader
dte_energy_bridge
duckdns
dunehd
duotecno
dwd_weather_warnings
dynalite
eafm
easyenergy
ecobee
ecoforest
econet
ecowitt
edl21
efergy
eight_sleep
electrasmart
electric_kiwi
elgato
elkm1
elmax
emonitor
emulated_hue
emulated_kasa
emulated_roku
energy
energyzero
enocean
enphase_envoy
environment_canada
epson
escea
esphome
eufylife_ble
event
everlights
evil_genius_labs
ezviz
faa_delays
facebook
facebox
fail2ban
fan
fastdotcom
feedreader
ffmpeg
fibaro
fido
file
file_upload
filesize
filter
fireservicerota
firmata
fitbit
fivem
fjaraskupan
flexit_bacnet
flic
flick_electric
flipr
flo
flume
flux
flux_led
folder
folder_watcher
foobot
forecast_solar
forked_daapd
foscam
freebox
freedns
freedompro
fritz
fritzbox
fritzbox_callmonitor
fronius
frontend
frontier_silicon
fully_kiosk
garages_amsterdam
gardena_bluetooth
gdacs
generic
generic_hygrostat
generic_thermostat
geo_json_events
geo_location
geo_rss_events
geocaching
geofency
geonetnz_quakes
geonetnz_volcano
gios
github
glances
goalzero
gogogate2
goodwe
google
google_assistant
google_assistant_sdk
google_domains
google_generative_ai_conversation
google_mail
google_pubsub
google_sheets
google_tasks
google_translate
google_travel_time
google_wifi
govee_ble
gpslogger
graphite
gree
greeneye_monitor
group
growatt_server
guardian
habitica
hardkernel
hardware
harmony
hassio
hddtemp
hdmi_cec
heos
here_travel_time
hisense_aehw4a1
history
history_stats
hive
hlk_sw16
holiday
home_connect
home_plus_control
homeassistant
homeassistant_alerts
homeassistant_green
homeassistant_hardware
homeassistant_sky_connect
homeassistant_yellow
homekit
homekit_controller
homematic
homematicip_cloud
homewizard
honeywell
html5
http
huawei_lte
hue
huisbaasje
humidifier
hunterdouglas_powerview
hvv_departures
hydrawise
hyperion
ialarm
iaqualink
ibeacon
icloud
idasen_desk
ifttt
ign_sismologia
image
image_processing
image_upload
imap
improv_ble
influxdb
inkbird
input_boolean
input_button
input_datetime
input_number
input_select
input_text
insteon
integration
intellifire
intent
intent_script
ios
iotawatt
ipma
ipp
iqvia
islamic_prayer_times
iss
isy994
izone
jellyfin
jewish_calendar
juicenet
justnimbus
jvc_projector
kaleidescape
keenetic_ndms2
kegtron
keymitt_ble
kira
kitchen_sink
kmtronic
knx
kodi
konnected
kostal_plenticore
kraken
kulersky
lacrosse_view
lametric
landisgyr_heat_meter
lastfm
launch_library
laundrify
lawn_mower
lcn
ld2410_ble
led_ble
lg_soundbar
lidarr
life360
lifx
light
linear_garage_door
litejet
litterrobot
livisi
local_calendar
local_file
local_ip
local_todo
locative
lock
logbook
logentries
logger
logi_circle
london_air
london_underground
lookin
loqed
lovelace
luftdaten
lutron_caseta
lyric
mailbox
mailgun
manual
manual_mqtt
marytts
matrix
matter
maxcube
mazda
meater
medcom_ble
media_extractor
media_player
media_source
melcloud
melissa
melnor
meraki
met
met_eireann
meteo_france
meteoclimatic
metoffice
mfi
microsoft
microsoft_face
microsoft_face_detect
microsoft_face_identify
mikrotik
mill
min_max
minecraft_server
minio
mjpeg
moat
mobile_app
mochad
modbus
modem_callerid
modern_forms
moehlenhoff_alpha2
mold_indicator
monoprice
moon
mopeka
motion_blinds
motioneye
motionmount
mqtt
mqtt_eventstream
mqtt_json
mqtt_room
mqtt_statestream
mullvad
mutesync
my
myq
mysensors
mystrom
mythicbeastsdns
nam
namecheapdns
nanoleaf
neato
ness_alarm
nest
netatmo
netgear
netgear_lte
network
nexia
nextbus
nextcloud
nextdns
nfandroidtv
nibe_heatpump
nightscout
nina
nmap_tracker
no_ip
nobo_hub
notify
notify_events
notion
nsw_fuel_station
nsw_rural_fire_service_feed
nuheat
nuki
numato
number
nut
nws
nx584
nzbget
obihai
octoprint
omnilogic
onboarding
oncue
ondilo_ico
onewire
onvif
open_meteo
openai_conversation
openalpr_cloud
openerz
openexchangerates
opengarage
openhardwaremonitor
openhome
opensky
opentherm_gw
openuv
openweathermap
opnsense
opower
oralb
osoenergy
otbr
ourgroceries
overkiz
ovo_energy
owntracks
p1_monitor
panasonic_viera
panel_custom
panel_iframe
peco
pegel_online
permobil
persistent_notification
person
philips_js
pi_hole
picnic
pilight
ping
pjlink
plaato
plant
plex
plugwise
plum_lightpad
point
poolsense
powerwall
private_ble_device
profiler
progettihwsw
prometheus
prosegur
proximity
prusalink
ps4
pure_energie
purpleair
push
pushbullet
pushover
pvoutput
pvpc_hourly_pricing
python_script
qbittorrent
qingping
qld_bushfire
qnap
qnap_qsw
qwikswitch
rachio
radarr
radio_browser
radiotherm
rainbird
rainforest_eagle
rainmachine
random
rapt_ble
raspberry_pi
rdw
recollect_waste
recorder
recovery_mode
reddit
refoss
remember_the_milk
remote
renault
renson
reolink
repairs
rest
rest_command
rflink
rfxtrx
rhasspy
ridwell
ring
risco
rituals_perfume_genie
rmvtransport
roborock
roku
roomba
roon
rpi_power
rss_feed_template
rtsp_to_webrtc
ruckus_unleashed
ruuvi_gateway
ruuvitag_ble
rympro
sabnzbd
samsungtv
scene
schedule
schlage
scrape
screenlogic
script
search
season
select
sense
sensibo
sensirion_ble
sensor
sensorpro
sensorpush
sentry
senz
seventeentrack
sfr_box
sharkiq
shell_command
shelly
shopping_list
sia
sigfox
sighthound
signal_messenger
simplepush
simplisafe
simulated
siren
skybell
slack
sleepiq
slimproto
sma
smappee
smart_meter_texas
smartthings
smarttub
smhi
smtp
snapcast
snips
snmp
snooz
solaredge
solarlog
solax
soma
somfy_mylink
sonarr
songpal
sonos
soundtouch
spaceapi
spc
speedtestdotnet
spider
spotify
sql
squeezebox
srp_energy
ssdp
starline
starlink
startca
statistics
statsd
steam_online
steamist
stookalert
stookwijzer
stream
streamlabswater
stt
subaru
suez_water
sun
sunweg
surepetcare
swiss_public_transport
switch
switch_as_x
switchbee
switchbot
switchbot_cloud
switcher_kis
syncthing
syncthru
synology_dsm
system_bridge
system_health
system_log
systemmonitor
tado
tag
tailscale
tailwind
tami4
tankerkoenig
tasmota
tautulli
tcp
telegram
telegram_bot
tellduslive
temper
template
tesla_wall_connector
tessie
text
thermobeacon
thermopro
thread
threshold
tibber
tile
tilt_ble
time
time_date
timer
tod
todo
todoist
tolo
tomato
tomorrowio
toon
totalconnect
tplink
tplink_omada
traccar
trace
tractive
tradfri
trafikverket_camera
trafikverket_ferry
trafikverket_train
trafikverket_weatherstation
transmission
transport_nsw
trend
tts
tuya
twentemilieu
twilio
twinkly
twitch
uk_transport
ukraine_alarm
unifi
unifiprotect
universal
upb
upcloud
update
upnp
uptime
uptimerobot
usb
usgs_earthquakes_feed
utility_meter
uvc
v2c
vacuum
vallox
valve
velbus
venstar
vera
verisure
version
vesync
vicare
vilfo
vizio
vlc_telnet
vodafone_station
voicerss
voip
volumio
volvooncall
vulcan
vultr
wake_on_lan
wake_word
wallbox
waqi
water_heater
watttime
waze_travel_time
weather
weatherflow
weatherkit
webhook
webostv
websocket_api
wemo
whirlpool
whois
wiffi
wilight
withings
wiz
wled
wolflink
workday
worldclock
ws66i
wsdot
wyoming
xbox
xiaomi
xiaomi_aqara
xiaomi_ble
xiaomi_miio
yale_smart_alarm
yalexs_ble
yamaha
yamaha_musiccast
yandex_transport
yandextts
yardian
yeelight
yolink
youless
youtube
zamg
zeroconf
zerproc
zeversolar
zha
__init__.py
common.py
conftest.py
data.py
test_alarm_control_panel.py
test_api.py
test_backup.py
test_base.py
test_binary_sensor.py
test_button.py
test_climate.py
test_cluster_handlers.py
test_config_flow.py
test_cover.py
test_device.py
test_device_action.py
test_device_tracker.py
test_device_trigger.py
test_diagnostics.py
test_discover.py
test_fan.py
test_gateway.py
test_helpers.py
test_init.py
test_light.py
test_lock.py
test_logbook.py
test_number.py
test_radio_manager.py
test_registries.py
test_repairs.py
test_select.py
test_sensor.py
test_silabs_multiprotocol.py
test_siren.py
test_switch.py
test_websocket_api.py
zha_devices_list.py
zodiac
zone
zwave_js
zwave_me
__init__.py
conftest.py
fixtures
hassfest
helpers
pylint
resources
scripts
snapshots
test_util
testing_config
util
__init__.py
common.py
conftest.py
ignore_uncaught_exceptions.py
patch_time.py
ruff.toml
syrupy.py
test_bootstrap.py
test_config.py
test_config_entries.py
test_const.py
test_core.py
test_data_entry_flow.py
test_exceptions.py
test_loader.py
test_main.py
test_requirements.py
test_runner.py
test_setup.py
test_test_fixtures.py
typing.py
.core_files.yaml
.coveragerc
.dockerignore
.gitattributes
.gitignore
.hadolint.yaml
.pre-commit-config.yaml
.prettierignore
.strict-typing
.yamllint
CLA.md
CODEOWNERS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile
Dockerfile.dev
LICENSE.md
MANIFEST.in
README.rst
build.yaml
codecov.yml
mypy.ini
pyproject.toml
requirements.txt
requirements_all.txt
requirements_test.txt
requirements_test_all.txt
requirements_test_pre_commit.txt

* Cache device triggers on startup * reorg zha init * don't reuse gateway * don't nuke yaml configuration * review comments * Add unit tests * Do not cache device and entity registries * [WIP] Wrap ZHA data in a dataclass * [WIP] Get unit tests passing * Use a helper function for getting the gateway object to fix annotations * Remove `bridge_id` * Fix typing issues with entity references in group websocket info * Use `Platform` instead of `str` for entity platform matching * Use `get_zha_gateway` in a few more places * Fix flaky unit test * Use `slots` for ZHA data Co-authored-by: J. Nick Koston <nick@koston.org> --------- Co-authored-by: David F. Mulcahey <david.mulcahey@icloud.com> Co-authored-by: J. Nick Koston <nick@koston.org>
373 lines
12 KiB
Python
373 lines
12 KiB
Python
"""The test for ZHA device automation actions."""
|
|
from unittest.mock import call, patch
|
|
|
|
import pytest
|
|
from pytest_unordered import unordered
|
|
from zhaquirks.inovelli.VZM31SN import InovelliVZM31SNv11
|
|
import zigpy.profiles.zha
|
|
import zigpy.zcl.clusters.general as general
|
|
import zigpy.zcl.clusters.security as security
|
|
import zigpy.zcl.foundation as zcl_f
|
|
|
|
import homeassistant.components.automation as automation
|
|
from homeassistant.components.device_automation import DeviceAutomationType
|
|
from homeassistant.components.zha import DOMAIN
|
|
from homeassistant.const import Platform
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
from .conftest import SIG_EP_INPUT, SIG_EP_OUTPUT, SIG_EP_TYPE
|
|
|
|
from tests.common import async_get_device_automations, async_mock_service
|
|
|
|
|
|
@pytest.fixture(autouse=True, name="stub_blueprint_populate")
|
|
def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
|
|
"""Stub copying the blueprints to the config folder."""
|
|
|
|
|
|
SHORT_PRESS = "remote_button_short_press"
|
|
COMMAND = "command"
|
|
COMMAND_SINGLE = "single"
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def required_platforms_only():
|
|
"""Only set up the required platforms and required base platforms to speed up tests."""
|
|
with patch(
|
|
"homeassistant.components.zha.PLATFORMS",
|
|
(
|
|
Platform.BINARY_SENSOR,
|
|
Platform.BUTTON,
|
|
Platform.DEVICE_TRACKER,
|
|
Platform.LIGHT,
|
|
Platform.NUMBER,
|
|
Platform.SELECT,
|
|
Platform.SENSOR,
|
|
Platform.SWITCH,
|
|
Platform.SIREN,
|
|
),
|
|
):
|
|
yield
|
|
|
|
|
|
@pytest.fixture
|
|
async def device_ias(hass, zigpy_device_mock, zha_device_joined_restored):
|
|
"""IAS device fixture."""
|
|
|
|
clusters = [general.Basic, security.IasZone, security.IasWd]
|
|
zigpy_device = zigpy_device_mock(
|
|
{
|
|
1: {
|
|
SIG_EP_INPUT: [c.cluster_id for c in clusters],
|
|
SIG_EP_OUTPUT: [general.OnOff.cluster_id],
|
|
SIG_EP_TYPE: zigpy.profiles.zha.DeviceType.ON_OFF_SWITCH,
|
|
}
|
|
},
|
|
)
|
|
|
|
zha_device = await zha_device_joined_restored(zigpy_device)
|
|
zha_device.update_available(True)
|
|
await hass.async_block_till_done()
|
|
return zigpy_device, zha_device
|
|
|
|
|
|
@pytest.fixture
|
|
async def device_inovelli(hass, zigpy_device_mock, zha_device_joined):
|
|
"""Inovelli device fixture."""
|
|
|
|
zigpy_device = zigpy_device_mock(
|
|
{
|
|
1: {
|
|
SIG_EP_INPUT: [
|
|
general.Basic.cluster_id,
|
|
general.Identify.cluster_id,
|
|
general.OnOff.cluster_id,
|
|
general.LevelControl.cluster_id,
|
|
0xFC31,
|
|
],
|
|
SIG_EP_OUTPUT: [],
|
|
SIG_EP_TYPE: zigpy.profiles.zha.DeviceType.DIMMABLE_LIGHT,
|
|
}
|
|
},
|
|
ieee="00:1d:8f:08:0c:90:69:6b",
|
|
manufacturer="Inovelli",
|
|
model="VZM31-SN",
|
|
quirk=InovelliVZM31SNv11,
|
|
)
|
|
|
|
zha_device = await zha_device_joined(zigpy_device)
|
|
zha_device.update_available(True)
|
|
await hass.async_block_till_done()
|
|
return zigpy_device, zha_device
|
|
|
|
|
|
async def test_get_actions(hass: HomeAssistant, device_ias) -> None:
|
|
"""Test we get the expected actions from a ZHA device."""
|
|
|
|
ieee_address = str(device_ias[0].ieee)
|
|
|
|
device_registry = dr.async_get(hass)
|
|
reg_device = device_registry.async_get_device(identifiers={(DOMAIN, ieee_address)})
|
|
entity_registry = er.async_get(hass)
|
|
siren_level_select = entity_registry.async_get(
|
|
"select.fakemanufacturer_fakemodel_default_siren_level"
|
|
)
|
|
siren_tone_select = entity_registry.async_get(
|
|
"select.fakemanufacturer_fakemodel_default_siren_tone"
|
|
)
|
|
strobe_level_select = entity_registry.async_get(
|
|
"select.fakemanufacturer_fakemodel_default_strobe_level"
|
|
)
|
|
strobe_select = entity_registry.async_get(
|
|
"select.fakemanufacturer_fakemodel_default_strobe"
|
|
)
|
|
|
|
actions = await async_get_device_automations(
|
|
hass, DeviceAutomationType.ACTION, reg_device.id
|
|
)
|
|
|
|
expected_actions = [
|
|
{
|
|
"domain": DOMAIN,
|
|
"type": "squawk",
|
|
"device_id": reg_device.id,
|
|
"metadata": {},
|
|
},
|
|
{"domain": DOMAIN, "type": "warn", "device_id": reg_device.id, "metadata": {}},
|
|
]
|
|
expected_actions.extend(
|
|
[
|
|
{
|
|
"domain": Platform.SELECT,
|
|
"type": action,
|
|
"device_id": reg_device.id,
|
|
"entity_id": entity_id,
|
|
"metadata": {"secondary": True},
|
|
}
|
|
for action in [
|
|
"select_first",
|
|
"select_last",
|
|
"select_next",
|
|
"select_option",
|
|
"select_previous",
|
|
]
|
|
for entity_id in [
|
|
siren_level_select.id,
|
|
siren_tone_select.id,
|
|
strobe_level_select.id,
|
|
strobe_select.id,
|
|
]
|
|
]
|
|
)
|
|
|
|
assert actions == unordered(expected_actions)
|
|
|
|
|
|
async def test_get_inovelli_actions(hass: HomeAssistant, device_inovelli) -> None:
|
|
"""Test we get the expected actions from a ZHA device."""
|
|
|
|
inovelli_ieee_address = str(device_inovelli[0].ieee)
|
|
device_registry = dr.async_get(hass)
|
|
inovelli_reg_device = device_registry.async_get_device(
|
|
identifiers={(DOMAIN, inovelli_ieee_address)}
|
|
)
|
|
entity_registry = er.async_get(hass)
|
|
inovelli_button = entity_registry.async_get("button.inovelli_vzm31_sn_identify")
|
|
inovelli_light = entity_registry.async_get("light.inovelli_vzm31_sn_light")
|
|
|
|
actions = await async_get_device_automations(
|
|
hass, DeviceAutomationType.ACTION, inovelli_reg_device.id
|
|
)
|
|
|
|
expected_actions = [
|
|
{
|
|
"device_id": inovelli_reg_device.id,
|
|
"domain": DOMAIN,
|
|
"metadata": {},
|
|
"type": "issue_all_led_effect",
|
|
},
|
|
{
|
|
"device_id": inovelli_reg_device.id,
|
|
"domain": DOMAIN,
|
|
"metadata": {},
|
|
"type": "issue_individual_led_effect",
|
|
},
|
|
{
|
|
"device_id": inovelli_reg_device.id,
|
|
"domain": Platform.BUTTON,
|
|
"entity_id": inovelli_button.id,
|
|
"metadata": {"secondary": True},
|
|
"type": "press",
|
|
},
|
|
{
|
|
"device_id": inovelli_reg_device.id,
|
|
"domain": Platform.LIGHT,
|
|
"entity_id": inovelli_light.id,
|
|
"metadata": {"secondary": False},
|
|
"type": "turn_off",
|
|
},
|
|
{
|
|
"device_id": inovelli_reg_device.id,
|
|
"domain": Platform.LIGHT,
|
|
"entity_id": inovelli_light.id,
|
|
"metadata": {"secondary": False},
|
|
"type": "turn_on",
|
|
},
|
|
{
|
|
"device_id": inovelli_reg_device.id,
|
|
"domain": Platform.LIGHT,
|
|
"entity_id": inovelli_light.id,
|
|
"metadata": {"secondary": False},
|
|
"type": "toggle",
|
|
},
|
|
{
|
|
"device_id": inovelli_reg_device.id,
|
|
"domain": Platform.LIGHT,
|
|
"entity_id": inovelli_light.id,
|
|
"metadata": {"secondary": False},
|
|
"type": "brightness_increase",
|
|
},
|
|
{
|
|
"device_id": inovelli_reg_device.id,
|
|
"domain": Platform.LIGHT,
|
|
"entity_id": inovelli_light.id,
|
|
"metadata": {"secondary": False},
|
|
"type": "brightness_decrease",
|
|
},
|
|
{
|
|
"device_id": inovelli_reg_device.id,
|
|
"domain": Platform.LIGHT,
|
|
"entity_id": inovelli_light.id,
|
|
"metadata": {"secondary": False},
|
|
"type": "flash",
|
|
},
|
|
]
|
|
|
|
assert actions == unordered(expected_actions)
|
|
|
|
|
|
async def test_action(hass: HomeAssistant, device_ias, device_inovelli) -> None:
|
|
"""Test for executing a ZHA device action."""
|
|
zigpy_device, zha_device = device_ias
|
|
inovelli_zigpy_device, inovelli_zha_device = device_inovelli
|
|
|
|
zigpy_device.device_automation_triggers = {
|
|
(SHORT_PRESS, SHORT_PRESS): {COMMAND: COMMAND_SINGLE}
|
|
}
|
|
|
|
ieee_address = str(zha_device.ieee)
|
|
inovelli_ieee_address = str(inovelli_zha_device.ieee)
|
|
|
|
device_registry = dr.async_get(hass)
|
|
reg_device = device_registry.async_get_device(identifiers={(DOMAIN, ieee_address)})
|
|
inovelli_reg_device = device_registry.async_get_device(
|
|
identifiers={(DOMAIN, inovelli_ieee_address)}
|
|
)
|
|
|
|
cluster = inovelli_zigpy_device.endpoints[1].in_clusters[0xFC31]
|
|
|
|
with patch(
|
|
"zigpy.zcl.Cluster.request",
|
|
return_value=[0x00, zcl_f.Status.SUCCESS],
|
|
):
|
|
assert await async_setup_component(
|
|
hass,
|
|
automation.DOMAIN,
|
|
{
|
|
automation.DOMAIN: [
|
|
{
|
|
"trigger": {
|
|
"device_id": reg_device.id,
|
|
"domain": "zha",
|
|
"platform": "device",
|
|
"type": SHORT_PRESS,
|
|
"subtype": SHORT_PRESS,
|
|
},
|
|
"action": [
|
|
{
|
|
"domain": DOMAIN,
|
|
"device_id": reg_device.id,
|
|
"type": "warn",
|
|
},
|
|
{
|
|
"domain": DOMAIN,
|
|
"device_id": inovelli_reg_device.id,
|
|
"type": "issue_all_led_effect",
|
|
"effect_type": "Open_Close",
|
|
"duration": 5,
|
|
"level": 10,
|
|
"color": 41,
|
|
},
|
|
{
|
|
"domain": DOMAIN,
|
|
"device_id": inovelli_reg_device.id,
|
|
"type": "issue_individual_led_effect",
|
|
"effect_type": "Falling",
|
|
"led_number": 1,
|
|
"duration": 5,
|
|
"level": 10,
|
|
"color": 41,
|
|
},
|
|
],
|
|
}
|
|
]
|
|
},
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
calls = async_mock_service(hass, DOMAIN, "warning_device_warn")
|
|
|
|
cluster_handler = zha_device.endpoints[1].client_cluster_handlers["1:0x0006"]
|
|
cluster_handler.zha_send_event(COMMAND_SINGLE, [])
|
|
await hass.async_block_till_done()
|
|
|
|
assert len(calls) == 1
|
|
assert calls[0].domain == DOMAIN
|
|
assert calls[0].service == "warning_device_warn"
|
|
assert calls[0].data["ieee"] == ieee_address
|
|
|
|
assert len(cluster.request.mock_calls) == 2
|
|
assert (
|
|
call(
|
|
False,
|
|
cluster.commands_by_name["led_effect"].id,
|
|
cluster.commands_by_name["led_effect"].schema,
|
|
6,
|
|
41,
|
|
10,
|
|
5,
|
|
expect_reply=False,
|
|
manufacturer=4151,
|
|
tsn=None,
|
|
)
|
|
in cluster.request.call_args_list
|
|
)
|
|
assert (
|
|
call(
|
|
False,
|
|
cluster.commands_by_name["individual_led_effect"].id,
|
|
cluster.commands_by_name["individual_led_effect"].schema,
|
|
1,
|
|
6,
|
|
41,
|
|
10,
|
|
5,
|
|
expect_reply=False,
|
|
manufacturer=4151,
|
|
tsn=None,
|
|
)
|
|
in cluster.request.call_args_list
|
|
)
|
|
|
|
|
|
async def test_invalid_zha_event_type(hass: HomeAssistant, device_ias) -> None:
|
|
"""Test that unexpected types are not passed to `zha_send_event`."""
|
|
zigpy_device, zha_device = device_ias
|
|
cluster_handler = zha_device._endpoints[1].client_cluster_handlers["1:0x0006"]
|
|
|
|
# `zha_send_event` accepts only zigpy responses, lists, and dicts
|
|
with pytest.raises(TypeError):
|
|
cluster_handler.zha_send_event(COMMAND_SINGLE, 123)
|