1 """Support for Melnor RainCloud sprinkler water timer."""
3 from datetime
import timedelta
6 from raincloudy.core
import RainCloudy
7 from requests.exceptions
import ConnectTimeout, HTTPError
8 import voluptuous
as vol
18 from .const
import DATA_RAINCLOUD, SIGNAL_UPDATE_RAINCLOUD
20 _LOGGER = logging.getLogger(__name__)
22 NOTIFICATION_ID =
"raincloud_notification"
23 NOTIFICATION_TITLE =
"Rain Cloud Setup"
29 CONFIG_SCHEMA = vol.Schema(
33 vol.Required(CONF_USERNAME): cv.string,
34 vol.Required(CONF_PASSWORD): cv.string,
35 vol.Optional(CONF_SCAN_INTERVAL, default=SCAN_INTERVAL): cv.time_period,
39 extra=vol.ALLOW_EXTRA,
43 def setup(hass: HomeAssistant, config: ConfigType) -> bool:
44 """Set up the Melnor RainCloud component."""
46 username = conf.get(CONF_USERNAME)
47 password = conf.get(CONF_PASSWORD)
48 scan_interval = conf.get(CONF_SCAN_INTERVAL)
51 raincloud = RainCloudy(username=username, password=password)
52 if not raincloud.is_connected:
55 except (ConnectTimeout, HTTPError)
as ex:
56 _LOGGER.error(
"Unable to connect to Rain Cloud service: %s",
str(ex))
57 persistent_notification.create(
59 f
"Error: {ex}<br />You will need to restart hass after fixing.",
60 title=NOTIFICATION_TITLE,
61 notification_id=NOTIFICATION_ID,
65 def hub_refresh(event_time):
66 """Call Raincloud hub to refresh information."""
67 _LOGGER.debug(
"Updating RainCloud Hub component")
68 hass.data[DATA_RAINCLOUD].data.update()
78 """Representation of a base RainCloud device."""
81 """Initialize the entity."""
bool setup(HomeAssistant hass, ConfigType config)
None dispatcher_send(HomeAssistant hass, str signal, *Any args)