Bump to google-nest-sdm to 4.0.4 (#117982)

pull/99304/head
Allen Porter 2024-05-23 11:27:48 -07:00 committed by GitHub
parent ef138eb976
commit 978fe2d7b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 48 additions and 38 deletions

View File

@ -10,7 +10,6 @@ from google_nest_sdm.device_traits import FanTrait, TemperatureTrait
from google_nest_sdm.exceptions import ApiException
from google_nest_sdm.thermostat_traits import (
ThermostatEcoTrait,
ThermostatHeatCoolTrait,
ThermostatHvacTrait,
ThermostatModeTrait,
ThermostatTemperatureSetpointTrait,
@ -173,7 +172,7 @@ class ThermostatEntity(ClimateEntity):
@property
def _target_temperature_trait(
self,
) -> ThermostatHeatCoolTrait | None:
) -> ThermostatEcoTrait | ThermostatTemperatureSetpointTrait | None:
"""Return the correct trait with a target temp depending on mode."""
if (
self.preset_mode == PRESET_ECO

View File

@ -20,7 +20,7 @@ from google_nest_sdm.exceptions import (
ConfigurationException,
SubscriberException,
)
from google_nest_sdm.structure import InfoTrait, Structure
from google_nest_sdm.structure import Structure
import voluptuous as vol
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry, ConfigFlowResult
@ -72,9 +72,9 @@ def _generate_subscription_id(cloud_project_id: str) -> str:
def generate_config_title(structures: Iterable[Structure]) -> str | None:
"""Pick a user friendly config title based on the Google Home name(s)."""
names: list[str] = [
trait.custom_name
structure.info.custom_name
for structure in structures
if (trait := structure.traits.get(InfoTrait.NAME)) and trait.custom_name
if structure.info and structure.info.custom_name
]
if not names:
return None

View File

@ -44,25 +44,26 @@ EVENT_CAMERA_SOUND = "camera_sound"
# that support these traits will generate Pub/Sub event messages in
# the EVENT_NAME_MAP
DEVICE_TRAIT_TRIGGER_MAP = {
DoorbellChimeTrait.NAME: EVENT_DOORBELL_CHIME,
CameraMotionTrait.NAME: EVENT_CAMERA_MOTION,
CameraPersonTrait.NAME: EVENT_CAMERA_PERSON,
CameraSoundTrait.NAME: EVENT_CAMERA_SOUND,
DoorbellChimeTrait.NAME.value: EVENT_DOORBELL_CHIME,
CameraMotionTrait.NAME.value: EVENT_CAMERA_MOTION,
CameraPersonTrait.NAME.value: EVENT_CAMERA_PERSON,
CameraSoundTrait.NAME.value: EVENT_CAMERA_SOUND,
}
# Mapping of incoming SDM Pub/Sub event message types to the home assistant
# event type to fire.
EVENT_NAME_MAP = {
DoorbellChimeEvent.NAME: EVENT_DOORBELL_CHIME,
CameraMotionEvent.NAME: EVENT_CAMERA_MOTION,
CameraPersonEvent.NAME: EVENT_CAMERA_PERSON,
CameraSoundEvent.NAME: EVENT_CAMERA_SOUND,
DoorbellChimeEvent.NAME.value: EVENT_DOORBELL_CHIME,
CameraMotionEvent.NAME.value: EVENT_CAMERA_MOTION,
CameraPersonEvent.NAME.value: EVENT_CAMERA_PERSON,
CameraSoundEvent.NAME.value: EVENT_CAMERA_SOUND,
}
# Names for event types shown in the media source
MEDIA_SOURCE_EVENT_TITLE_MAP = {
DoorbellChimeEvent.NAME: "Doorbell",
CameraMotionEvent.NAME: "Motion",
CameraPersonEvent.NAME: "Person",
CameraSoundEvent.NAME: "Sound",
DoorbellChimeEvent.NAME.value: "Doorbell",
CameraMotionEvent.NAME.value: "Motion",
CameraPersonEvent.NAME.value: "Person",
CameraSoundEvent.NAME.value: "Sound",
}

View File

@ -20,5 +20,5 @@
"iot_class": "cloud_push",
"loggers": ["google_nest_sdm"],
"quality_scale": "platinum",
"requirements": ["google-nest-sdm==3.0.4"]
"requirements": ["google-nest-sdm==4.0.4"]
}

View File

@ -977,7 +977,7 @@ google-cloud-texttospeech==2.12.3
google-generativeai==0.5.4
# homeassistant.components.nest
google-nest-sdm==3.0.4
google-nest-sdm==4.0.4
# homeassistant.components.google_travel_time
googlemaps==2.5.1

View File

@ -803,7 +803,7 @@ google-cloud-pubsub==2.13.11
google-generativeai==0.5.4
# homeassistant.components.nest
google-nest-sdm==3.0.4
google-nest-sdm==4.0.4
# homeassistant.components.google_travel_time
googlemaps==2.5.1

View File

@ -9,8 +9,16 @@
dict({
'data': dict({
'name': '**REDACTED**',
'parentRelations': list([
]),
'traits': dict({
'sdm.devices.traits.CameraLiveStream': dict({
'audioCodecs': list([
]),
'maxVideoResolution': dict({
'height': None,
'width': None,
}),
'supportedProtocols': list([
'RTSP',
]),
@ -28,7 +36,6 @@
# name: test_device_diagnostics
dict({
'data': dict({
'assignee': '**REDACTED**',
'name': '**REDACTED**',
'parentRelations': list([
dict({
@ -38,13 +45,13 @@
]),
'traits': dict({
'sdm.devices.traits.Humidity': dict({
'ambientHumidityPercent': 35.0,
'ambient_humidity_percent': 35.0,
}),
'sdm.devices.traits.Info': dict({
'customName': '**REDACTED**',
'custom_name': '**REDACTED**',
}),
'sdm.devices.traits.Temperature': dict({
'ambientTemperatureCelsius': 25.1,
'ambient_temperature_celsius': 25.1,
}),
}),
'type': 'sdm.devices.types.THERMOSTAT',
@ -56,7 +63,6 @@
'devices': list([
dict({
'data': dict({
'assignee': '**REDACTED**',
'name': '**REDACTED**',
'parentRelations': list([
dict({
@ -66,13 +72,13 @@
]),
'traits': dict({
'sdm.devices.traits.Humidity': dict({
'ambientHumidityPercent': 35.0,
'ambient_humidity_percent': 35.0,
}),
'sdm.devices.traits.Info': dict({
'customName': '**REDACTED**',
'custom_name': '**REDACTED**',
}),
'sdm.devices.traits.Temperature': dict({
'ambientTemperatureCelsius': 25.1,
'ambient_temperature_celsius': 25.1,
}),
}),
'type': 'sdm.devices.types.THERMOSTAT',

View File

@ -109,7 +109,7 @@ def make_motion_event(
"""Create an EventMessage for a motion event."""
if not timestamp:
timestamp = utcnow()
return EventMessage(
return EventMessage.create_event(
{
"eventId": "some-event-id", # Ignored; we use the resource updated event id below
"timestamp": timestamp.isoformat(timespec="seconds"),

View File

@ -79,7 +79,7 @@ async def create_event(
async def create_event(traits: dict[str, Any]) -> None:
await subscriber.async_receive_event(
EventMessage(
EventMessage.create_event(
{
"eventId": EVENT_ID,
"timestamp": "2019-01-01T00:00:01Z",

View File

@ -457,7 +457,7 @@ async def test_subscriber_automation(
assert await setup_automation(hass, device_entry.id, "camera_motion")
# Simulate a pubsub message received by the subscriber with a motion event
event = EventMessage(
event = EventMessage.create_event(
{
"eventId": "some-event-id",
"timestamp": "2019-01-01T00:00:01Z",

View File

@ -104,7 +104,7 @@ def create_events(events, device_id=DEVICE_ID, timestamp=None):
"""Create an EventMessage for events."""
if not timestamp:
timestamp = utcnow()
return EventMessage(
return EventMessage.create_event(
{
"eventId": "some-event-id",
"timestamp": timestamp.isoformat(timespec="seconds"),
@ -264,7 +264,7 @@ async def test_event_message_without_device_event(
events = async_capture_events(hass, NEST_EVENT)
await setup_platform()
timestamp = utcnow()
event = EventMessage(
event = EventMessage.create_event(
{
"eventId": "some-event-id",
"timestamp": timestamp.isoformat(timespec="seconds"),
@ -321,7 +321,9 @@ async def test_doorbell_event_thread(
"eventThreadState": "STARTED",
}
)
await subscriber.async_receive_event(EventMessage(message_data_1, auth=None))
await subscriber.async_receive_event(
EventMessage.create_event(message_data_1, auth=None)
)
# Publish message #2 that sends a no-op update to end the event thread
timestamp2 = timestamp1 + datetime.timedelta(seconds=1)
@ -332,7 +334,9 @@ async def test_doorbell_event_thread(
"eventThreadState": "ENDED",
}
)
await subscriber.async_receive_event(EventMessage(message_data_2, auth=None))
await subscriber.async_receive_event(
EventMessage.create_event(message_data_2, auth=None)
)
await hass.async_block_till_done()
# The event is only published once
@ -449,7 +453,7 @@ async def test_structure_update_event(
assert not registry.async_get("camera.back")
# Send a message that triggers the device to be loaded
message = EventMessage(
message = EventMessage.create_event(
{
"eventId": "some-event-id",
"timestamp": utcnow().isoformat(timespec="seconds"),

View File

@ -196,7 +196,7 @@ def create_event_message(event_data, timestamp, device_id=None):
"""Create an EventMessage for a single event type."""
if device_id is None:
device_id = DEVICE_ID
return EventMessage(
return EventMessage.create_event(
{
"eventId": f"{EVENT_ID}-{timestamp}",
"timestamp": timestamp.isoformat(timespec="seconds"),

View File

@ -215,7 +215,7 @@ async def test_event_updates_sensor(
assert temperature.state == "25.1"
# Simulate a pubsub message received by the subscriber with a trait update
event = EventMessage(
event = EventMessage.create_event(
{
"eventId": "some-event-id",
"timestamp": "2019-01-01T00:00:01Z",