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

This commit is contained in:
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.exceptions import ApiException
from google_nest_sdm.thermostat_traits import ( from google_nest_sdm.thermostat_traits import (
ThermostatEcoTrait, ThermostatEcoTrait,
ThermostatHeatCoolTrait,
ThermostatHvacTrait, ThermostatHvacTrait,
ThermostatModeTrait, ThermostatModeTrait,
ThermostatTemperatureSetpointTrait, ThermostatTemperatureSetpointTrait,
@ -173,7 +172,7 @@ class ThermostatEntity(ClimateEntity):
@property @property
def _target_temperature_trait( def _target_temperature_trait(
self, self,
) -> ThermostatHeatCoolTrait | None: ) -> ThermostatEcoTrait | ThermostatTemperatureSetpointTrait | None:
"""Return the correct trait with a target temp depending on mode.""" """Return the correct trait with a target temp depending on mode."""
if ( if (
self.preset_mode == PRESET_ECO self.preset_mode == PRESET_ECO

View File

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

View File

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

View File

@ -20,5 +20,5 @@
"iot_class": "cloud_push", "iot_class": "cloud_push",
"loggers": ["google_nest_sdm"], "loggers": ["google_nest_sdm"],
"quality_scale": "platinum", "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 google-generativeai==0.5.4
# homeassistant.components.nest # homeassistant.components.nest
google-nest-sdm==3.0.4 google-nest-sdm==4.0.4
# homeassistant.components.google_travel_time # homeassistant.components.google_travel_time
googlemaps==2.5.1 googlemaps==2.5.1

View File

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

View File

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

View File

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

View File

@ -79,7 +79,7 @@ async def create_event(
async def create_event(traits: dict[str, Any]) -> None: async def create_event(traits: dict[str, Any]) -> None:
await subscriber.async_receive_event( await subscriber.async_receive_event(
EventMessage( EventMessage.create_event(
{ {
"eventId": EVENT_ID, "eventId": EVENT_ID,
"timestamp": "2019-01-01T00:00:01Z", "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") assert await setup_automation(hass, device_entry.id, "camera_motion")
# Simulate a pubsub message received by the subscriber with a motion event # Simulate a pubsub message received by the subscriber with a motion event
event = EventMessage( event = EventMessage.create_event(
{ {
"eventId": "some-event-id", "eventId": "some-event-id",
"timestamp": "2019-01-01T00:00:01Z", "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.""" """Create an EventMessage for events."""
if not timestamp: if not timestamp:
timestamp = utcnow() timestamp = utcnow()
return EventMessage( return EventMessage.create_event(
{ {
"eventId": "some-event-id", "eventId": "some-event-id",
"timestamp": timestamp.isoformat(timespec="seconds"), "timestamp": timestamp.isoformat(timespec="seconds"),
@ -264,7 +264,7 @@ async def test_event_message_without_device_event(
events = async_capture_events(hass, NEST_EVENT) events = async_capture_events(hass, NEST_EVENT)
await setup_platform() await setup_platform()
timestamp = utcnow() timestamp = utcnow()
event = EventMessage( event = EventMessage.create_event(
{ {
"eventId": "some-event-id", "eventId": "some-event-id",
"timestamp": timestamp.isoformat(timespec="seconds"), "timestamp": timestamp.isoformat(timespec="seconds"),
@ -321,7 +321,9 @@ async def test_doorbell_event_thread(
"eventThreadState": "STARTED", "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 # Publish message #2 that sends a no-op update to end the event thread
timestamp2 = timestamp1 + datetime.timedelta(seconds=1) timestamp2 = timestamp1 + datetime.timedelta(seconds=1)
@ -332,7 +334,9 @@ async def test_doorbell_event_thread(
"eventThreadState": "ENDED", "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() await hass.async_block_till_done()
# The event is only published once # The event is only published once
@ -449,7 +453,7 @@ async def test_structure_update_event(
assert not registry.async_get("camera.back") assert not registry.async_get("camera.back")
# Send a message that triggers the device to be loaded # Send a message that triggers the device to be loaded
message = EventMessage( message = EventMessage.create_event(
{ {
"eventId": "some-event-id", "eventId": "some-event-id",
"timestamp": utcnow().isoformat(timespec="seconds"), "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.""" """Create an EventMessage for a single event type."""
if device_id is None: if device_id is None:
device_id = DEVICE_ID device_id = DEVICE_ID
return EventMessage( return EventMessage.create_event(
{ {
"eventId": f"{EVENT_ID}-{timestamp}", "eventId": f"{EVENT_ID}-{timestamp}",
"timestamp": timestamp.isoformat(timespec="seconds"), "timestamp": timestamp.isoformat(timespec="seconds"),

View File

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