Support for Salda Smarty XV/XP Ventilation Unit (#21491)
* Support for Salda Smarty XV/XP Ventilation Unit * Update binary_sensor.py * Update fan.py * Update sensor.py * Update __init__.py
This commit is contained in:
1 parent
bf7e09ce59
commit
6cd9667364
8 files changed
+500
No files matched your search
@@ -0,0 +1,71 @@
|
||||
"""Support to control a Salda Smarty XP/XV ventilation unit."""
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
import ipaddress
|
||||
import logging
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import (CONF_NAME, CONF_HOST)
|
||||
from homeassistant.helpers import discovery
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import dispatcher_send
|
||||
from homeassistant.helpers.event import track_time_interval
|
||||
|
||||
DOMAIN = 'smarty'
|
||||
DATA_SMARTY = 'smarty'
|
||||
SMARTY_NAME = 'Smarty'
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.Schema({
|
||||
vol.Required(CONF_HOST): vol.All(ipaddress.ip_address, cv.string),
|
||||
vol.Optional(CONF_NAME, default=SMARTY_NAME): cv.string
|
||||
}),
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA)
|
||||
|
||||
RPM = 'rpm'
|
||||
SIGNAL_UPDATE_SMARTY = 'smarty_update'
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Set up the smarty environment."""
|
||||
from pysmarty import (Smarty)
|
||||
conf = config[DOMAIN]
|
||||
|
||||
host = conf[CONF_HOST]
|
||||
name = conf[CONF_NAME]
|
||||
|
||||
_LOGGER.debug("Name: %s, host: %s", name, host)
|
||||
|
||||
smarty = Smarty(host=host)
|
||||
|
||||
hass.data[DOMAIN] = {
|
||||
'api': smarty,
|
||||
'name': name
|
||||
}
|
||||
|
||||
# Initial update
|
||||
smarty.update()
|
||||
|
||||
# Load platforms
|
||||
discovery.load_platform(hass, 'fan', DOMAIN, {}, config)
|
||||
discovery.load_platform(hass, 'sensor', DOMAIN, {}, config)
|
||||
discovery.load_platform(hass, 'binary_sensor', DOMAIN, {}, config)
|
||||
|
||||
def poll_device_update(event_time):
|
||||
"""Update Smarty device."""
|
||||
_LOGGER.debug("Updating Smarty device...")
|
||||
if smarty.update():
|
||||
_LOGGER.debug("Update success...")
|
||||
dispatcher_send(hass, SIGNAL_UPDATE_SMARTY)
|
||||
else:
|
||||
_LOGGER.debug("Update failed...")
|
||||
|
||||
track_time_interval(hass, poll_device_update,
|
||||
timedelta(seconds=30))
|
||||
|
||||
return True
|
||||
Reference in new issue
Block a user