I’m taking a stab at creating an irrigation component to support the Rachio irrigation system within HASS. I’m primarily a Node.js developer, so excuse any stupid mistakes I might have made so far here in Python.
I’m trying to just get a very basic proof-of-concept working at the moment. I have created an irrigation
folder inside my custom_components
folder with the __init__.py
and the rachio.py
files. This is what I have so far:
configuration.yaml
irrigation:
platform: rachio
api_key: !secret rachio_api_key
irrigation/init.py
"""
Support for Irrigation devices.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/irrigation/
"""
import asyncio
from datetime import timedelta
import logging
import voluptuous as vol
from homeassistant.config import load_yaml_config_file
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa
import homeassistant.helpers.config_validation as cv
from homeassistant.components import group
DOMAIN = 'irrigation'
SCAN_INTERVAL = timedelta(seconds=15)
GROUP_NAME_ALL_IRRIGATION = 'all irrigation'
ENTITY_ID_ALL_IRRIGATION = group.ENTITY_ID_FORMAT.format('all_irrigation')
ENTITY_ID_FORMAT = DOMAIN + '.{}'
_LOGGER = logging.getLogger(__name__)
class IrrigationDevice(Entity):
"""Representation of an irrigation system."""
# pylint: disable=no-self-use
@property
def current_zone_state(self):
"""Return current zone state.
None in unknown, off is off, on is on.
"""
pass
irrigation/rachio.py
"""
Support for Rachio Irrigation Systems.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/irrigation.rachio/
"""
import logging
import voluptuous as vol
from homeassistant.components.irrigation import IrrigationDevice
from homeassistant.const import (
CONF_API_KEY)
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['https://github.com/rfverbruggen/rachiopy/archive/master.zip']
IRRIGATION_SCHEMA = vol.Schema({
vol.Required(CONF_API_KEY): cv.string
})
DEFAULT_NAME = 'rachio'
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Rachio component."""
from rachiopy import Rachio as rachiopy
api_key = config.get(CONF_API_KEY)
logger = logging.getLogger(__name__)
rachio = rachiopy(api_key)
rachio.person.getInfo()
When I restart HASS, I get the following messages in the log:
17-04-24 00:06:53 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.irrigation.rachio. Make sure all dependencies are installed
17-04-24 00:06:53 ERROR (MainThread) [homeassistant.loader] Unable to find component irrigation.rachio
17-04-24 00:06:53 ERROR (MainThread) [homeassistant.setup] Error during setup of component irrigation
I have installed the rachiopy dependency like so:
git clone https://github.com/rfverbruggen/rachiopy.git
pip install ./rachiopy --target ../home/hass/deps
As you can see, I’m trying to call a very basic getInfo()
method just to know it’s working (which, of course, it isn’t). Would anyone be so kind into giving me some pointers on where to go from here?