more changes for dictionary unpacking

This commit is contained in:
John Lancaster
2024-08-27 19:14:26 -05:00
parent a8e0b53c53
commit 4114fb4c54
8 changed files with 26 additions and 386 deletions

View File

@@ -2,26 +2,28 @@ import asyncio
import json
from appdaemon.adapi import ADAPI
from appdaemon.adbase import ADBase
from appdaemon.plugins.hass.hassapi import Hass
class HelloWorld(Hass):
class MyClass(Hass):
def initialize(self):
self.log('Hello World')
# self.listen_state(
# callback=self.temp_callback,
# entity_id='sensor.temperature_nest',
# attribute='state',
# threshold=65.0,
# )
# self.listen_state(
# callback=self.temp_callback,
# entity_id='light.living_room',
# attribute='state',
# threshold=65.0,
# )
return
async def temp_callback(self, entity, attribute, old, new, kwargs):
def my_callback(self, title: str, message: str, **kwargs) -> None:
self.log(f'{title}: {message}')
self.log(kwargs)
class HelloWorld(ADBase):
def initialize(self):
self.adapi = self.get_ad_api()
def my_callback(self, cb_args: dict) -> None:
self.adapi.log(f'{cb_args["title"]}: {cb_args["message"]}')
async def temp_callback(self, entity, attribute, old, new, **kwargs):
self.log('Temp callback')
temp = await self.get_state('sensor.temperature_nest')
# self.log(json.dumps(temp, indent=4))