1 """Support for Google Mail Sensors."""
3 from __future__
import annotations
5 from datetime
import UTC, datetime, timedelta
7 from googleapiclient.http
import HttpRequest
12 SensorEntityDescription,
17 from .
import GoogleMailConfigEntry
18 from .entity
import GoogleMailEntity
23 key=
"vacation_end_date",
24 translation_key=
"vacation_end_date",
25 device_class=SensorDeviceClass.TIMESTAMP,
31 entry: GoogleMailConfigEntry,
32 async_add_entities: AddEntitiesCallback,
34 """Set up the Google Mail sensor."""
39 """Representation of a Google Mail sensor."""
42 """Get the vacation data."""
44 settings: HttpRequest = service.users().settings().getVacation(userId=
"me")
45 data: dict = await self.
hasshass.async_add_executor_job(settings.execute)
47 if data[
"enableAutoReply"]
and (end := data.get(
"endTime")):
48 value = datetime.fromtimestamp(
int(end) / 1000, tz=UTC)
None async_setup_entry(HomeAssistant hass, GoogleMailConfigEntry entry, AddEntitiesCallback async_add_entities)
str get_resource(str domain_name, ConfigType domain_data)