mirror of
https://github.com/home-assistant/core.git
synced 2025-08-11 14:29:58 +00:00
.devcontainer
.github
.vscode
homeassistant
machine
pylint
rootfs
script
tests
auth
components
abode
acaia
accuweather
acmeda
adax
adguard
advantage_air
aemet
aftership
agent_dvr
air_quality
airgradient
airly
airnow
airq
airthings
airthings_ble
airtouch4
airtouch5
airvisual
airvisual_pro
airzone
airzone_cloud
aladdin_connect
alarm_control_panel
alarmdecoder
alert
alexa
amberelectric
ambient_network
ambient_station
analytics
analytics_insights
android_ip_webcam
androidtv
androidtv_remote
anova
anthemav
anthropic
aosmith
apache_kafka
apcupsd
api
api_streams
apple_tv
application_credentials
apprise
aprilaire
aprs
apsystems
aquacell
aranet
arcam_fmj
arve
aseko_pool_live
assist_pipeline
assist_satellite
asuswrt
atag
august
aurora
aurora_abb_powerone
aussie_broadband
autarco
auth
automation
awair
aws
axis
azure_data_explorer
azure_devops
azure_event_hub
azure_storage
backup
baf
balboa
bang_olufsen
bayesian
binary_sensor
blackbird
blebox
blink
blue_current
bluemaestro
blueprint
bluesound
bluetooth
bluetooth_adapters
bluetooth_le_tracker
bmw_connected_drive
bond
bosch_alarm
bosch_shc
braviatv
bring
broadlink
brother
brottsplatskartan
brunt
bryant_evolution
bsblan
bthome
buienradar
button
caldav
calendar
cambridge_audio
camera
canary
cast
ccm15
cert_expiry
chacon_dio
clicksend_tts
climate
cloud
cloudflare
co2signal
coinbase
color_extractor
comelit
comfoconnect
command_line
compensation
config
configurator
control4
conversation
cookidoo
coolmaster
counter
cover
cpuspeed
crownstone
daikin
datadog
date
datetime
deako
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
downloader
dremel_3d_printer
drop_connect
dsmr
dsmr_reader
duckdns
duke_energy
dunehd
duotecno
dwd_weather_warnings
dynalite
eafm
easyenergy
ecobee
ecoforest
econet
ecovacs
ecowitt
edl21
efergy
eheimdigital
eight_sleep
electrasmart
electric_kiwi
elevenlabs
elgato
elkm1
elmax
elvia
emoncms
emonitor
emulated_hue
emulated_kasa
emulated_roku
energenie_power_sockets
energy
energyzero
enigma2
enocean
enphase_envoy
environment_canada
epic_games_store
epion
epson
eq3btsmart
escea
esphome
eufylife_ble
event
everlights
evil_genius_labs
evohome
ezviz
faa_delays
facebook
fail2ban
fan
fastdotcom
feedreader
ffmpeg
fibaro
fido
file
file_upload
filesize
filter
fints
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
fujitsu_fglair
fully_kiosk
fyta
garages_amsterdam
gardena_bluetooth
gdacs
generic
generic_hygrostat
generic_thermostat
geniushub
geo_json_events
geo_location
geo_rss_events
geocaching
geofency
geonetnz_quakes
geonetnz_volcano
gios
github
glances
go2rtc
goalzero
gogogate2
goodwe
google
google_assistant
google_assistant_sdk
google_cloud
google_drive
google_generative_ai_conversation
google_mail
google_photos
google_pubsub
google_sheets
google_tasks
google_translate
google_travel_time
google_wifi
govee_ble
govee_light_local
gpsd
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
hko
hlk_sw16
holiday
home_connect
homeassistant
homeassistant_alerts
homeassistant_green
homeassistant_hardware
homeassistant_sky_connect
homeassistant_yellow
homee
homekit
homekit_controller
homematic
homematicip_cloud
homewizard
homeworks
honeywell
html5
http
huawei_lte
hue
huisbaasje
humidifier
hunterdouglas_powerview
husqvarna_automower
husqvarna_automower_ble
huum
hvv_departures
hydrawise
hyperion
ialarm
iaqualink
ibeacon
icloud
idasen_desk
ifttt
igloohome
ign_sismologia
image
image_processing
image_upload
imap
imeon_inverter
imgw_pib
improv_ble
incomfort
influxdb
inkbird
input_boolean
input_button
input_datetime
input_number
input_select
input_text
insteon
integration
intellifire
intent
intent_script
iometer
ios
iotawatt
iotty
ipma
ipp
iqvia
iron_os
isal
iskra
islamic_prayer_times
israel_rail
iss
ista_ecotrend
isy994
ituran
izone
jellyfin
jewish_calendar
juicenet
justnimbus
jvc_projector
kaleidescape
keenetic_ndms2
kegtron
keymitt_ble
kira
kitchen_sink
kmtronic
knocki
knx
kodi
konnected
kostal_plenticore
kraken
kulersky
lacrosse_view
lamarzocco
lametric
landisgyr_heat_meter
lastfm
launch_library
laundrify
lawn_mower
lcn
ld2410_ble
leaone
led_ble
lektrico
letpot
lg_netcast
lg_soundbar
lg_thinq
lidarr
life360
lifx
light
linear_garage_door
linkplay
litejet
litterrobot
livisi
local_calendar
local_file
local_ip
local_todo
locative
lock
logbook
logentries
logger
london_air
london_underground
lookin
loqed
lovelace
luftdaten
lupusec
lutron
lutron_caseta
lyric
madvr
mailgun
manual
manual_mqtt
marytts
mastodon
matrix
matter
maxcube
mazda
mcp
mcp_server
mealie
meater
medcom_ble
media_extractor
media_player
media_source
melcloud
melissa
melnor
meraki
met
met_eireann
meteo_france
meteoclimatic
metoffice
mfi
microbees
microsoft
microsoft_face
microsoft_face_detect
microsoft_face_identify
miele
mikrotik
mill
min_max
minecraft_server
minio
mjpeg
moat
mobile_app
mochad
modbus
modem_callerid
modern_forms
moehlenhoff_alpha2
mold_indicator
monarch_money
monoprice
monzo
moon
mopeka
motion_blinds
motionblinds_ble
motioneye
motionmount
mpd
mqtt
mqtt_eventstream
mqtt_json
mqtt_room
mqtt_statestream
mullvad
music_assistant
mutesync
my
myq
mysensors
mystrom
mythicbeastsdns
myuplink
nam
namecheapdns
nanoleaf
nasweb
neato
ness_alarm
nest
netatmo
netgear
netgear_lte
network
nexia
nextbus
nextcloud
nextdns
nfandroidtv
nibe_heatpump
nice_go
nightscout
niko_home_control
nina
nmap_tracker
nmbs
no_ip
nobo_hub
nordpool
notify
notify_events
notion
nsw_fuel_station
nsw_rural_fire_service_feed
nuheat
nuki
numato
number
nut
nws
nx584
nyt_games
nzbget
obihai
octoprint
ohme
ollama
omnilogic
onboarding
oncue
ondilo_ico
onedrive
onewire
onkyo
onvif
open_meteo
openai_conversation
openalpr_cloud
openerz
openexchangerates
opengarage
openhardwaremonitor
openhome
opensky
opentherm_gw
openuv
openweathermap
opnsense
opower
oralb
osoenergy
otbr
otp
ourgroceries
overkiz
overseerr
ovo_energy
owntracks
p1_monitor
palazzetti
panasonic_viera
panel_custom
peblar
peco
pegel_online
permobil
persistent_notification
person
pglab
philips_js
pi_hole
picnic
pilight
ping
pjlink
plaato
plant
plex
plugwise
plum_lightpad
point
poolsense
powerfox
powerwall
private_ble_device
profiler
progettihwsw
prometheus
prosegur
proximity
prusalink
ps4
pterodactyl
pure_energie
purpleair
push
pushbullet
pushover
pvoutput
pvpc_hourly_pricing
pyload
python_script
qbittorrent
qbus
qingping
qld_bushfire
qnap
qnap_qsw
qwikswitch
rabbitair
rachio
radarr
radio_browser
radiotherm
rainbird
rainforest_eagle
rainforest_raven
rainmachine
random
rapt_ble
raspberry_pi
rdw
recollect_waste
recorder
recovery_mode
reddit
refoss
remember_the_milk
remote
remote_calendar
renault
renson
reolink
repairs
rest
rest_command
rflink
rfxtrx
rhasspy
ridwell
ring
risco
rituals_perfume_genie
rmvtransport
roborock
roku
romy
roomba
roon
rova
rpi_power
rss_feed_template
rtsp_to_webrtc
ruckus_unleashed
russound_rio
ruuvi_gateway
ruuvitag_ble
rympro
sabnzbd
samsungtv
sanix
scene
schedule
schlage
scrape
screenlogic
script
search
season
select
sense
sensibo
sensirion_ble
sensor
sensorpro
sensorpush
sensorpush_cloud
sensoterra
sentry
senz
seventeentrack
sfr_box
sharkiq
shell_command
shelly
shopping_list
sia
sigfox
sighthound
signal_messenger
simplefin
simplepush
simplisafe
siren
sky_remote
skybell
slack
sleepiq
slide_local
slimproto
sma
smappee
smart_meter_texas
smartthings
smarttub
smarty
smhi
smlight
sms
smtp
snapcast
snips
snmp
snoo
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
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
technove
tedee
telegram
telegram_bot
tellduslive
temper
template
fixtures
snapshots
__init__.py
conftest.py
test_alarm_control_panel.py
test_binary_sensor.py
test_blueprint.py
test_button.py
test_config.py
test_config_flow.py
test_cover.py
test_entity.py
test_fan.py
test_image.py
test_init.py
test_light.py
test_lock.py
test_number.py
test_select.py
test_sensor.py
test_switch.py
test_template_entity.py
test_trigger.py
test_trigger_entity.py
test_vacuum.py
test_weather.py
tesla_fleet
tesla_wall_connector
teslemetry
tessie
text
thermobeacon
thermopro
thethingsnetwork
thread
threshold
tibber
tile
tilt_ble
time
time_date
timer
tod
todo
todoist
tolo
tomato
tomorrowio
toon
totalconnect
touchline_sl
tplink
tplink_omada
traccar
traccar_server
trace
tractive
tradfri
trafikverket_camera
trafikverket_ferry
trafikverket_train
trafikverket_weatherstation
transmission
transport_nsw
trend
triggercmd
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
velux
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
watergate
watttime
waze_travel_time
weather
weatherflow
weatherflow_cloud
weatherkit
webdav
webhook
webmin
webostv
websocket_api
weheat
wemo
whirlpool
whois
wiffi
wilight
withings
wiz
wled
wmspro
wolflink
workday
worldclock
ws66i
wsdot
wyoming
xbox
xiaomi
xiaomi_aqara
xiaomi_ble
xiaomi_miio
yale
yale_smart_alarm
yalexs_ble
yamaha
yamaha_musiccast
yandex_transport
yandextts
yardian
yeelight
yolink
youless
youtube
zamg
zeroconf
zerproc
zeversolar
zha
zodiac
zone
zwave_js
zwave_me
__init__.py
conftest.py
fixtures
hassfest
helpers
non_packaged_scripts
pylint
resources
script
scripts
snapshots
test_util
testing_config
util
__init__.py
common.py
conftest.py
ignore_uncaught_exceptions.py
patch_recorder.py
patch_time.py
ruff.toml
syrupy.py
test_backports.py
test_backup_restore.py
test_block_async_io.py
test_bootstrap.py
test_circular_imports.py
test_config.py
test_config_entries.py
test_const.py
test_core.py
test_core_config.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
.dockerignore
.git-blame-ignore-revs
.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

* Apply fix * Add tests for alarm button cover lock * update light * add number tests * test select * add switch tests * test vacuum * update lock test
333 lines
9.0 KiB
Python
333 lines
9.0 KiB
Python
"""The tests for the Template button platform."""
|
|
|
|
import datetime as dt
|
|
from typing import Any
|
|
|
|
from freezegun.api import FrozenDateTimeFactory
|
|
import pytest
|
|
from syrupy.assertion import SnapshotAssertion
|
|
|
|
from homeassistant import setup
|
|
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
|
from homeassistant.components.template import DOMAIN
|
|
from homeassistant.components.template.button import DEFAULT_NAME
|
|
from homeassistant.const import (
|
|
CONF_DEVICE_CLASS,
|
|
CONF_ENTITY_ID,
|
|
CONF_FRIENDLY_NAME,
|
|
CONF_ICON,
|
|
STATE_UNKNOWN,
|
|
)
|
|
from homeassistant.core import HomeAssistant, ServiceCall
|
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
|
|
|
from tests.common import MockConfigEntry, assert_setup_component
|
|
|
|
_TEST_BUTTON = "button.template_button"
|
|
_TEST_OPTIONS_BUTTON = "button.test"
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"config_entry_extra_options",
|
|
[
|
|
{},
|
|
{
|
|
"device_class": "update",
|
|
},
|
|
],
|
|
)
|
|
async def test_setup_config_entry(
|
|
hass: HomeAssistant,
|
|
snapshot: SnapshotAssertion,
|
|
config_entry_extra_options: dict[str, str],
|
|
) -> None:
|
|
"""Test the config flow."""
|
|
|
|
template_config_entry = MockConfigEntry(
|
|
data={},
|
|
domain=DOMAIN,
|
|
options={
|
|
"name": "My template",
|
|
"template_type": "button",
|
|
"press": [
|
|
{
|
|
"service": "input_boolean.toggle",
|
|
"metadata": {},
|
|
"data": {},
|
|
"target": {"entity_id": "input_boolean.test"},
|
|
}
|
|
],
|
|
}
|
|
| config_entry_extra_options,
|
|
title="My template",
|
|
)
|
|
template_config_entry.add_to_hass(hass)
|
|
|
|
assert await hass.config_entries.async_setup(template_config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
state = hass.states.get("button.my_template")
|
|
assert state is not None
|
|
assert state == snapshot
|
|
|
|
|
|
async def test_missing_optional_config(hass: HomeAssistant) -> None:
|
|
"""Test: missing optional template is ok."""
|
|
with assert_setup_component(1, "template"):
|
|
assert await setup.async_setup_component(
|
|
hass,
|
|
"template",
|
|
{
|
|
"template": {
|
|
"button": {
|
|
"press": {"service": "script.press"},
|
|
},
|
|
}
|
|
},
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
await hass.async_start()
|
|
await hass.async_block_till_done()
|
|
|
|
_verify(hass, STATE_UNKNOWN)
|
|
|
|
|
|
async def test_missing_emtpy_press_action_config(
|
|
hass: HomeAssistant,
|
|
freezer: FrozenDateTimeFactory,
|
|
) -> None:
|
|
"""Test: missing optional template is ok."""
|
|
with assert_setup_component(1, "template"):
|
|
assert await setup.async_setup_component(
|
|
hass,
|
|
"template",
|
|
{
|
|
"template": {
|
|
"button": {
|
|
"press": [],
|
|
},
|
|
}
|
|
},
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
await hass.async_start()
|
|
await hass.async_block_till_done()
|
|
|
|
_verify(hass, STATE_UNKNOWN)
|
|
|
|
now = dt.datetime.now(dt.UTC)
|
|
freezer.move_to(now)
|
|
await hass.services.async_call(
|
|
BUTTON_DOMAIN,
|
|
SERVICE_PRESS,
|
|
{CONF_ENTITY_ID: _TEST_BUTTON},
|
|
blocking=True,
|
|
)
|
|
|
|
_verify(
|
|
hass,
|
|
now.isoformat(),
|
|
)
|
|
|
|
|
|
async def test_missing_required_keys(hass: HomeAssistant) -> None:
|
|
"""Test: missing required fields will fail."""
|
|
with assert_setup_component(0, "template"):
|
|
assert await setup.async_setup_component(
|
|
hass,
|
|
"template",
|
|
{"template": {"button": {}}},
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
await hass.async_start()
|
|
await hass.async_block_till_done()
|
|
|
|
assert hass.states.async_all("button") == []
|
|
|
|
|
|
async def test_all_optional_config(
|
|
hass: HomeAssistant,
|
|
entity_registry: er.EntityRegistry,
|
|
freezer: FrozenDateTimeFactory,
|
|
calls: list[ServiceCall],
|
|
) -> None:
|
|
"""Test: including all optional templates is ok."""
|
|
with assert_setup_component(1, "template"):
|
|
assert await setup.async_setup_component(
|
|
hass,
|
|
"template",
|
|
{
|
|
"template": {
|
|
"unique_id": "test",
|
|
"button": {
|
|
"press": {
|
|
"service": "test.automation",
|
|
"data_template": {"caller": "{{ this.entity_id }}"},
|
|
},
|
|
"device_class": "restart",
|
|
"unique_id": "test",
|
|
"name": "test",
|
|
"icon": "mdi:test",
|
|
},
|
|
}
|
|
},
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
await hass.async_start()
|
|
await hass.async_block_till_done()
|
|
|
|
_verify(
|
|
hass,
|
|
STATE_UNKNOWN,
|
|
{
|
|
CONF_DEVICE_CLASS: "restart",
|
|
CONF_FRIENDLY_NAME: "test",
|
|
CONF_ICON: "mdi:test",
|
|
},
|
|
_TEST_OPTIONS_BUTTON,
|
|
)
|
|
|
|
now = dt.datetime.now(dt.UTC)
|
|
freezer.move_to(now)
|
|
await hass.services.async_call(
|
|
BUTTON_DOMAIN,
|
|
SERVICE_PRESS,
|
|
{CONF_ENTITY_ID: _TEST_OPTIONS_BUTTON},
|
|
blocking=True,
|
|
)
|
|
|
|
assert len(calls) == 1
|
|
assert calls[0].data["caller"] == _TEST_OPTIONS_BUTTON
|
|
|
|
_verify(
|
|
hass,
|
|
now.isoformat(),
|
|
{
|
|
CONF_DEVICE_CLASS: "restart",
|
|
CONF_FRIENDLY_NAME: "test",
|
|
CONF_ICON: "mdi:test",
|
|
},
|
|
_TEST_OPTIONS_BUTTON,
|
|
)
|
|
|
|
assert entity_registry.async_get_entity_id("button", "template", "test-test")
|
|
|
|
|
|
async def test_name_template(hass: HomeAssistant) -> None:
|
|
"""Test: name template."""
|
|
with assert_setup_component(1, "template"):
|
|
assert await setup.async_setup_component(
|
|
hass,
|
|
"template",
|
|
{
|
|
"template": {
|
|
"button": {
|
|
"press": {"service": "script.press"},
|
|
"name": "Button {{ 1 + 1 }}",
|
|
},
|
|
}
|
|
},
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
await hass.async_start()
|
|
await hass.async_block_till_done()
|
|
|
|
_verify(
|
|
hass,
|
|
STATE_UNKNOWN,
|
|
{
|
|
CONF_FRIENDLY_NAME: "Button 2",
|
|
},
|
|
"button.button_2",
|
|
)
|
|
|
|
|
|
async def test_unique_id(hass: HomeAssistant) -> None:
|
|
"""Test: unique id is ok."""
|
|
with assert_setup_component(1, "template"):
|
|
assert await setup.async_setup_component(
|
|
hass,
|
|
"template",
|
|
{
|
|
"template": {
|
|
"unique_id": "test",
|
|
"button": {
|
|
"press": {"service": "script.press"},
|
|
"unique_id": "test",
|
|
},
|
|
}
|
|
},
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
await hass.async_start()
|
|
await hass.async_block_till_done()
|
|
|
|
_verify(hass, STATE_UNKNOWN)
|
|
|
|
|
|
def _verify(
|
|
hass: HomeAssistant,
|
|
expected_value: str,
|
|
attributes: dict[str, Any] | None = None,
|
|
entity_id: str = _TEST_BUTTON,
|
|
) -> None:
|
|
"""Verify button's state."""
|
|
attributes = attributes or {}
|
|
if CONF_FRIENDLY_NAME not in attributes:
|
|
attributes[CONF_FRIENDLY_NAME] = DEFAULT_NAME
|
|
state = hass.states.get(entity_id)
|
|
assert state.state == expected_value
|
|
assert state.attributes == attributes
|
|
|
|
|
|
async def test_device_id(
|
|
hass: HomeAssistant,
|
|
device_registry: dr.DeviceRegistry,
|
|
entity_registry: er.EntityRegistry,
|
|
) -> None:
|
|
"""Test for device for button template."""
|
|
|
|
device_config_entry = MockConfigEntry()
|
|
device_config_entry.add_to_hass(hass)
|
|
device_entry = device_registry.async_get_or_create(
|
|
config_entry_id=device_config_entry.entry_id,
|
|
identifiers={("test", "identifier_test")},
|
|
connections={("mac", "30:31:32:33:34:35")},
|
|
)
|
|
await hass.async_block_till_done()
|
|
assert device_entry is not None
|
|
assert device_entry.id is not None
|
|
|
|
template_config_entry = MockConfigEntry(
|
|
data={},
|
|
domain=DOMAIN,
|
|
options={
|
|
"name": "My template",
|
|
"template_type": "button",
|
|
"device_id": device_entry.id,
|
|
"press": [
|
|
{
|
|
"service": "input_boolean.toggle",
|
|
"metadata": {},
|
|
"data": {},
|
|
"target": {"entity_id": "input_boolean.test"},
|
|
}
|
|
],
|
|
},
|
|
title="My template",
|
|
)
|
|
template_config_entry.add_to_hass(hass)
|
|
|
|
assert await hass.config_entries.async_setup(template_config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
template_entity = entity_registry.async_get("button.my_template")
|
|
assert template_entity is not None
|
|
assert template_entity.device_id == device_entry.id
|