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:
Paulus Schoutsen 2023-04-26 22:13:21 -04:00 committed by GitHub
parent 13fc22aa3c
commit ddc2807361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 26 deletions

View File

@ -1,8 +1,13 @@
{ {
"entity": { "entity": {
"binary_sensor": {
"assist_in_progress": {
"name": "Assist in progress"
}
},
"select": { "select": {
"pipeline": { "pipeline": {
"name": "Assist Pipeline", "name": "Assist pipeline",
"state": { "state": {
"preferred": "Preferred" "preferred": "Preferred"
} }

View File

@ -34,7 +34,7 @@ async def async_setup_entry(
entry_data = DomainData.get(hass).get_entry_data(entry) entry_data = DomainData.get(hass).get_entry_data(entry)
assert entry_data.device_info is not None assert entry_data.device_info is not None
if entry_data.device_info.voice_assistant_version: if entry_data.device_info.voice_assistant_version:
async_add_entities([EsphomeCallActiveBinarySensor(entry_data)]) async_add_entities([EsphomeAssistInProgressBinarySensor(entry_data)])
class EsphomeBinarySensor( class EsphomeBinarySensor(
@ -68,12 +68,12 @@ class EsphomeBinarySensor(
return super().available return super().available
class EsphomeCallActiveBinarySensor(EsphomeAssistEntity, BinarySensorEntity): class EsphomeAssistInProgressBinarySensor(EsphomeAssistEntity, BinarySensorEntity):
"""A binary sensor implementation for ESPHome for use with assist_pipeline.""" """A binary sensor implementation for ESPHome for use with assist_pipeline."""
entity_description = BinarySensorEntityDescription( entity_description = BinarySensorEntityDescription(
key="call_active", key="assist_in_progress",
translation_key="call_active", translation_key="assist_in_progress",
) )
@property @property

View File

@ -48,8 +48,8 @@
}, },
"entity": { "entity": {
"binary_sensor": { "binary_sensor": {
"call_active": { "assist_in_progress": {
"name": "Call Active" "name": "[%key:component::assist_pipeline::entity::binary_sensor::assist_in_progress::name%]"
} }
}, },
"select": { "select": {

View File

@ -31,19 +31,19 @@ async def async_setup_entry(
@callback @callback
def async_add_device(device: VoIPDevice) -> None: def async_add_device(device: VoIPDevice) -> None:
"""Add device.""" """Add device."""
async_add_entities([VoIPCallActive(device)]) async_add_entities([VoIPCallInProgress(device)])
domain_data.devices.async_add_new_device_listener(async_add_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): class VoIPCallInProgress(VoIPEntity, BinarySensorEntity):
"""Entity to represent voip is allowed.""" """Entity to represent voip call is in progress."""
entity_description = BinarySensorEntityDescription( entity_description = BinarySensorEntityDescription(
key="call_active", key="call_in_progress",
translation_key="call_active", translation_key="call_in_progress",
) )
_attr_is_on = False _attr_is_on = False

View File

@ -11,13 +11,13 @@
}, },
"entity": { "entity": {
"binary_sensor": { "binary_sensor": {
"call_active": { "call_in_progress": {
"name": "Call Active" "name": "Call in progress"
} }
}, },
"switch": { "switch": {
"allow_call": { "allow_call": {
"name": "Allow Calls" "name": "Allow calls"
} }
}, },
"select": { "select": {

View File

@ -5,24 +5,24 @@ from homeassistant.components.esphome import DomainData
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
async def test_call_active( async def test_assist_in_progress(
hass: HomeAssistant, hass: HomeAssistant,
mock_voice_assistant_v1_entry, mock_voice_assistant_v1_entry,
) -> None: ) -> 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) 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 is not None
assert state.state == "off" assert state.state == "off"
entry_data.async_set_assist_pipeline_state(True) 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" assert state.state == "on"
entry_data.async_set_assist_pipeline_state(False) 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" assert state.state == "off"

View File

@ -4,22 +4,22 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
async def test_allow_call( async def test_call_in_progress(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
voip_device: VoIPDevice, voip_device: VoIPDevice,
) -> None: ) -> None:
"""Test allow call.""" """Test call in progress."""
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 is not None assert state is not None
assert state.state == "off" assert state.state == "off"
voip_device.set_is_active(True) 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" assert state.state == "on"
voip_device.set_is_active(False) 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" assert state.state == "off"