Skip to content

Instantly share code, notes, and snippets.

import appdaemon.plugins.hass.hassapi as hass
import voluptuous as vol
import time
## YAML CONFIG
# hvac_cool_switch:
# module: climateswitch
# class: ClimateSwitch
# climate: climate.hvac_cool
# switch: group.house_coolers
import appdaemon.plugins.hass.hassapi as hass
import datetime
# YAML CONFIG
# battery:
# module: battery
# class: Battery
# threshold: 35
# always_send: False
# th:
@dlashua
dlashua / notify_alexa.py
Created August 13, 2019 10:21
notify alexa
devices = [
{
"device_entity": "media_player.dance_echo",
"active_entity": "binary_sensor.dance_echo_notifications",
},
{
"device_entity": "media_player.celeste_echo",
"active_entity": "binary_sensor.celestebed_echo_notifications",
},
{
@dlashua
dlashua / alexaalarms.py
Last active September 2, 2019 13:27
alexaalarms.py
import appdaemon.plugins.hass.hassapi as hass
import datetime
import re
import pprint
from alexapy import AlexaLogin, AlexaAPI
BASE_DIR = "/conf/apps/"
ALEXA_DIR = BASE_DIR + "alexa_files/"
UPDATE_INTERVAL = 60 * 1
@dlashua
dlashua / test.py
Created August 24, 2019 18:06
coros in AppDaemon
import appdaemon.plugins.hass.hassapi as hass
import asyncio
class Test(hass.Hass):
def terminate(self):
# clean up after ourselves
for f in self.futures:
f.cancel()
@dlashua
dlashua / app_reloader.py
Last active August 28, 2019 14:32
AppDaemon 4 Method for Dynamic App Reloading
import adbase as ad
import re
class AppReloader(ad.ADBase):
def initialize(self):
self.adbase = self.get_ad_api()
self.adbase.listen_event(
self.announce_dependency_event_cb,
@dlashua
dlashua / test.py
Last active October 7, 2022 13:12
Async Apps in AppDaemon Example
import appdaemon.plugins.hass.hassapi as hass
import asyncio
class TestAllAsync(hass.Hass):
async def terminate(self):
self.log('i will die in 3 seconds')
await asyncio.sleep(3)
self.log('i am dead')
@dlashua
dlashua / appmodule.py
Last active December 11, 2021 07:09
a base app in AppDaemon
import appdaemon.plugins.hass.hassapi as hass
import base
class MyApp(hass.Hass):
def initialize(self):
self.depends_on_module(base)
base.App(self)
res = self.something()
self.log(res) # logs "thing" from base.py
@dlashua
dlashua / app.py
Created September 2, 2019 16:40
Dynamic App Dependencies
class app(hass.Hass):
def initialize(self):
helper = self.get_app('helper')
helper.add_dependent(self.name)
self.log(helper.do_a_thing())
@dlashua
dlashua / app.py
Last active September 2, 2019 20:12
import gm_dlashua_statewatcher as statewatcher
import appdaemon.plugins.hass.hassapi as hass
AllState = statewatcher.AllState
class App(hass.Hass):
def initalize(self):
self.register_dependency(statewatcher)