From 978fe2d7b0648a02ff6cd7d231b80c05f83eb125 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Thu, 23 May 2024 11:27:48 -0700 Subject: [PATCH] Bump to google-nest-sdm to 4.0.4 (#117982) --- homeassistant/components/nest/climate.py | 3 +-- homeassistant/components/nest/config_flow.py | 6 ++--- homeassistant/components/nest/events.py | 25 ++++++++++--------- homeassistant/components/nest/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- .../nest/snapshots/test_diagnostics.ambr | 22 ++++++++++------ tests/components/nest/test_camera.py | 2 +- tests/components/nest/test_climate.py | 2 +- tests/components/nest/test_device_trigger.py | 2 +- tests/components/nest/test_events.py | 14 +++++++---- tests/components/nest/test_media_source.py | 2 +- tests/components/nest/test_sensor.py | 2 +- 13 files changed, 48 insertions(+), 38 deletions(-) diff --git a/homeassistant/components/nest/climate.py b/homeassistant/components/nest/climate.py index 411389f9fb2..03fb641d0e5 100644 --- a/homeassistant/components/nest/climate.py +++ b/homeassistant/components/nest/climate.py @@ -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 diff --git a/homeassistant/components/nest/config_flow.py b/homeassistant/components/nest/config_flow.py index 7b5f5d2c5fb..29ae9f6a08e 100644 --- a/homeassistant/components/nest/config_flow.py +++ b/homeassistant/components/nest/config_flow.py @@ -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 diff --git a/homeassistant/components/nest/events.py b/homeassistant/components/nest/events.py index 752ab0e5069..76a5069f563 100644 --- a/homeassistant/components/nest/events.py +++ b/homeassistant/components/nest/events.py @@ -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", } diff --git a/homeassistant/components/nest/manifest.json b/homeassistant/components/nest/manifest.json index 354066e2d87..5a975bb19ec 100644 --- a/homeassistant/components/nest/manifest.json +++ b/homeassistant/components/nest/manifest.json @@ -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"] } diff --git a/requirements_all.txt b/requirements_all.txt index 9881f7839a7..8e4874dab43 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 3b869e3feb4..d35409066ad 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -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 diff --git a/tests/components/nest/snapshots/test_diagnostics.ambr b/tests/components/nest/snapshots/test_diagnostics.ambr index 8ffc218d7c9..aa679b8821c 100644 --- a/tests/components/nest/snapshots/test_diagnostics.ambr +++ b/tests/components/nest/snapshots/test_diagnostics.ambr @@ -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', diff --git a/tests/components/nest/test_camera.py b/tests/components/nest/test_camera.py index 33c611c9cfc..29d942f2a7b 100644 --- a/tests/components/nest/test_camera.py +++ b/tests/components/nest/test_camera.py @@ -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"), diff --git a/tests/components/nest/test_climate.py b/tests/components/nest/test_climate.py index 3aab77c4759..05ce5ad80f1 100644 --- a/tests/components/nest/test_climate.py +++ b/tests/components/nest/test_climate.py @@ -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", diff --git a/tests/components/nest/test_device_trigger.py b/tests/components/nest/test_device_trigger.py index 44fb6bcf701..5bb4b1c859a 100644 --- a/tests/components/nest/test_device_trigger.py +++ b/tests/components/nest/test_device_trigger.py @@ -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", diff --git a/tests/components/nest/test_events.py b/tests/components/nest/test_events.py index caa86a3d93b..25e04ba2aa7 100644 --- a/tests/components/nest/test_events.py +++ b/tests/components/nest/test_events.py @@ -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"), diff --git a/tests/components/nest/test_media_source.py b/tests/components/nest/test_media_source.py index 419b3648124..7d6a14ba04e 100644 --- a/tests/components/nest/test_media_source.py +++ b/tests/components/nest/test_media_source.py @@ -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"), diff --git a/tests/components/nest/test_sensor.py b/tests/components/nest/test_sensor.py index 65a74eb93e0..f3434b420da 100644 --- a/tests/components/nest/test_sensor.py +++ b/tests/components/nest/test_sensor.py @@ -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",