mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Fix capitalization names Assist entities (#92098)
* Fix capitalization names Assist entities * Adjust names to be 'in progress' * Update tests/components/esphome/test_binary_sensor.py Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --------- Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
13fc22aa3c
commit
ddc2807361
@ -1,8 +1,13 @@
|
||||
{
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"assist_in_progress": {
|
||||
"name": "Assist in progress"
|
||||
}
|
||||
},
|
||||
"select": {
|
||||
"pipeline": {
|
||||
"name": "Assist Pipeline",
|
||||
"name": "Assist pipeline",
|
||||
"state": {
|
||||
"preferred": "Preferred"
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ async def async_setup_entry(
|
||||
entry_data = DomainData.get(hass).get_entry_data(entry)
|
||||
assert entry_data.device_info is not None
|
||||
if entry_data.device_info.voice_assistant_version:
|
||||
async_add_entities([EsphomeCallActiveBinarySensor(entry_data)])
|
||||
async_add_entities([EsphomeAssistInProgressBinarySensor(entry_data)])
|
||||
|
||||
|
||||
class EsphomeBinarySensor(
|
||||
@ -68,12 +68,12 @@ class EsphomeBinarySensor(
|
||||
return super().available
|
||||
|
||||
|
||||
class EsphomeCallActiveBinarySensor(EsphomeAssistEntity, BinarySensorEntity):
|
||||
class EsphomeAssistInProgressBinarySensor(EsphomeAssistEntity, BinarySensorEntity):
|
||||
"""A binary sensor implementation for ESPHome for use with assist_pipeline."""
|
||||
|
||||
entity_description = BinarySensorEntityDescription(
|
||||
key="call_active",
|
||||
translation_key="call_active",
|
||||
key="assist_in_progress",
|
||||
translation_key="assist_in_progress",
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -48,8 +48,8 @@
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"call_active": {
|
||||
"name": "Call Active"
|
||||
"assist_in_progress": {
|
||||
"name": "[%key:component::assist_pipeline::entity::binary_sensor::assist_in_progress::name%]"
|
||||
}
|
||||
},
|
||||
"select": {
|
||||
|
@ -31,19 +31,19 @@ async def async_setup_entry(
|
||||
@callback
|
||||
def async_add_device(device: VoIPDevice) -> None:
|
||||
"""Add device."""
|
||||
async_add_entities([VoIPCallActive(device)])
|
||||
async_add_entities([VoIPCallInProgress(device)])
|
||||
|
||||
domain_data.devices.async_add_new_device_listener(async_add_device)
|
||||
|
||||
async_add_entities([VoIPCallActive(device) for device in domain_data.devices])
|
||||
async_add_entities([VoIPCallInProgress(device) for device in domain_data.devices])
|
||||
|
||||
|
||||
class VoIPCallActive(VoIPEntity, BinarySensorEntity):
|
||||
"""Entity to represent voip is allowed."""
|
||||
class VoIPCallInProgress(VoIPEntity, BinarySensorEntity):
|
||||
"""Entity to represent voip call is in progress."""
|
||||
|
||||
entity_description = BinarySensorEntityDescription(
|
||||
key="call_active",
|
||||
translation_key="call_active",
|
||||
key="call_in_progress",
|
||||
translation_key="call_in_progress",
|
||||
)
|
||||
_attr_is_on = False
|
||||
|
||||
|
@ -11,13 +11,13 @@
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"call_active": {
|
||||
"name": "Call Active"
|
||||
"call_in_progress": {
|
||||
"name": "Call in progress"
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"allow_call": {
|
||||
"name": "Allow Calls"
|
||||
"name": "Allow calls"
|
||||
}
|
||||
},
|
||||
"select": {
|
||||
|
@ -5,24 +5,24 @@ from homeassistant.components.esphome import DomainData
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
async def test_call_active(
|
||||
async def test_assist_in_progress(
|
||||
hass: HomeAssistant,
|
||||
mock_voice_assistant_v1_entry,
|
||||
) -> None:
|
||||
"""Test call active binary sensor."""
|
||||
"""Test assist in progress binary sensor."""
|
||||
|
||||
entry_data = DomainData.get(hass).get_entry_data(mock_voice_assistant_v1_entry)
|
||||
|
||||
state = hass.states.get("binary_sensor.test_call_active")
|
||||
state = hass.states.get("binary_sensor.test_assist_in_progress")
|
||||
assert state is not None
|
||||
assert state.state == "off"
|
||||
|
||||
entry_data.async_set_assist_pipeline_state(True)
|
||||
|
||||
state = hass.states.get("binary_sensor.test_call_active")
|
||||
state = hass.states.get("binary_sensor.test_assist_in_progress")
|
||||
assert state.state == "on"
|
||||
|
||||
entry_data.async_set_assist_pipeline_state(False)
|
||||
|
||||
state = hass.states.get("binary_sensor.test_call_active")
|
||||
state = hass.states.get("binary_sensor.test_assist_in_progress")
|
||||
assert state.state == "off"
|
||||
|
@ -4,22 +4,22 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
async def test_allow_call(
|
||||
async def test_call_in_progress(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
voip_device: VoIPDevice,
|
||||
) -> None:
|
||||
"""Test allow call."""
|
||||
state = hass.states.get("binary_sensor.192_168_1_210_call_active")
|
||||
"""Test call in progress."""
|
||||
state = hass.states.get("binary_sensor.192_168_1_210_call_in_progress")
|
||||
assert state is not None
|
||||
assert state.state == "off"
|
||||
|
||||
voip_device.set_is_active(True)
|
||||
|
||||
state = hass.states.get("binary_sensor.192_168_1_210_call_active")
|
||||
state = hass.states.get("binary_sensor.192_168_1_210_call_in_progress")
|
||||
assert state.state == "on"
|
||||
|
||||
voip_device.set_is_active(False)
|
||||
|
||||
state = hass.states.get("binary_sensor.192_168_1_210_call_active")
|
||||
state = hass.states.get("binary_sensor.192_168_1_210_call_in_progress")
|
||||
assert state.state == "off"
|
||||
|
Loading…
x
Reference in New Issue
Block a user