more changes for dictionary unpacking
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user