Skip to content

Instantly share code, notes, and snippets.

@dlashua
dlashua / README.md
Created October 13, 2020 12:26
PyScript Candle Light Simulator

Use this in a Home Assistant Automation or Script to start a candle light effect on a bulb.

action:
  - service: pyscript.candle_light
    data:
      entity_id: light.living_overhead
      state: 'on' #use 'off' to stop the effect
      brightness: 12 #optional
 color_temp: 450 #optional
@dlashua
dlashua / other_app.py
Created November 14, 2019 11:39
Example App Service
# Using Events
class OtherApp:
def initialize(self):
self.fire_event('spotify.start', volume=100)
# Using get_app()
class OtherApp:
def initialize(self):
self.get_app('start_spotify').start(volume=100)
@dlashua
dlashua / apps.yaml
Last active November 5, 2019 11:58
daysequence AppDaemon App
celestebed_color_lights:
module: dlashua_daysequence
class: DaySequenceEvent
days_list:
- option: halloween
start:
month: 10
day: 1
end:
month: 11
@dlashua
dlashua / app.py
Created September 22, 2019 12:57
AD TESTS
import appdaemon.plugins.hass.hassapi as hass
import datetime
def timer_cb(kwargs):
print('timer_cb {}'.format(kwargs))
TESTS_RUN_AND_DONE = [
'list_namespaces',
'sun_up',
@dlashua
dlashua / app.py
Last active September 20, 2019 12:25
AD Condition Engine
import appdaemon.plugins.hass.hassapi as hass
import conditions
class CTest(hass.Hass):
def initialize(self):
self.depends_on_module(conditions)
self._conditions = {}
# put in adapi.__init__
@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)
@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 / 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 / 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 / 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,