Pierre Wessman 7b45d19308 init
2025-01-16 16:22:58 +01:00

27 lines
799 B
Python

import asyncio
import json
from ..base_plugin import BasePlugin
class Plugin(BasePlugin):
def __init__(self, config: dict) -> None:
super().__init__(config=config)
def tool_get_calendar_events(self, entity_id=None, days=3):
"""
Get users calendar events.
"""
if entity_id is None:
entity_id = self.config["plugins"]["calendar"]["default_calendar"]
response = asyncio.run(
self.homeassistant.send_command(
"call_service",
domain="calendar",
service="get_events",
target={"entity_id": entity_id},
service_data={"duration": {"days": days}},
return_response=True,
)
)
return json.dumps(response)