mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add LiteJet (a lighting control system) component (#4125)
* Initial submission of LiteJet integration. * Add LiteJet switch pressed automation trigger. (State changes are too slow to catch a press-release.) Add LiteJet scene, replacing commented out code that treated these as lights. Include LiteJet numbers in the device state so that it is easy to lookup entity -> number. * Fix missing global. * Allow light's brightness to be set explicitly. * Support optional 'ignore' key to ignore prefixes of loads, switches, and scenes that weren't configured for use in the LiteJet system. * Fix lint errors and warnings. * Cleanup header comments. Default to not creating LiteJet switches as these are generally not useful. * Lint fixes. * Fixes from pull request feedback. * Use hass.data instead of globals for data storage. * Fix lint warnings.
This commit is contained in:
committed by
Paulus Schoutsen
parent
2a7b7ebd6a
commit
ba13951fff
41
homeassistant/components/automation/litejet.py
Normal file
41
homeassistant/components/automation/litejet.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
Trigger an automation when a LiteJet switch is released.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/automation.litejet/
|
||||
"""
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.const import CONF_PLATFORM
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
DEPENDENCIES = ['litejet']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_NUMBER = 'number'
|
||||
|
||||
TRIGGER_SCHEMA = vol.Schema({
|
||||
vol.Required(CONF_PLATFORM): 'litejet',
|
||||
vol.Required(CONF_NUMBER): cv.positive_int
|
||||
})
|
||||
|
||||
|
||||
def async_trigger(hass, config, action):
|
||||
"""Listen for events based on configuration."""
|
||||
number = config.get(CONF_NUMBER)
|
||||
|
||||
@callback
|
||||
def call_action():
|
||||
"""Call action with right context."""
|
||||
hass.async_run_job(action, {
|
||||
'trigger': {
|
||||
CONF_PLATFORM: 'litejet',
|
||||
CONF_NUMBER: number
|
||||
},
|
||||
})
|
||||
|
||||
hass.data['litejet_system'].on_switch_released(number, call_action)
|
||||
Reference in New Issue
Block a user