Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
35df350
Starting to add attributes
bachya Apr 26, 2018
562db55
All attributes added to programs
bachya Apr 26, 2018
6bbfddc
Basic zone attributes in place
bachya Apr 26, 2018
786d8d6
Added advanced properties for zones
bachya Apr 26, 2018
f202550
We shouldn't calculate the MAC with every entity
bachya May 1, 2018
b7a32be
Small fixes
bachya May 1, 2018
ad4d90a
Restart
bachya May 6, 2018
88d0c4d
Restart part 2
bachya May 6, 2018
881f65d
Basic framework for push in play
bachya May 6, 2018
db7b419
I THINK IT'S WORKING
bachya May 6, 2018
d784e5a
Some state cleanup
bachya May 6, 2018
f622091
Added stub for service schema
bachya May 7, 2018
f8734e7
Update
bachya May 7, 2018
8286b52
Added services
bachya May 7, 2018
44d9aa0
Small service description update
bachya May 7, 2018
935ea9b
Lint
bachya May 7, 2018
c1fb770
Updated CODEOWNERS
bachya May 7, 2018
57891cb
Moving to async methods
bachya May 8, 2018
9d1edb3
Fixed coverage test
bachya May 8, 2018
c0f446d
Lint
bachya May 8, 2018
bfa3ddb
Removed unnecessary hass reference
bachya May 8, 2018
856959a
Lint
bachya May 9, 2018
6bdc2da
Lint
bachya May 9, 2018
4cb581c
Round 1 of Owner-requested changes
bachya May 18, 2018
63cc18c
Round 2 of Owner-requested changes
bachya May 18, 2018
4b16dba
Round 3 of Owner-requested changes
bachya May 18, 2018
6e65971
Round 4 (final for now) of Owner-requested changes
bachya May 18, 2018
5293789
Hound
bachya May 18, 2018
3832bb1
Updated package requirements
bachya May 18, 2018
2f40713
Lint
bachya May 18, 2018
014f657
Collaborator-requested changes
bachya May 28, 2018
a4039bb
Collaborator-requested changes
bachya May 28, 2018
45ddf36
More small tweaks
bachya May 28, 2018
0cb1b9a
One more small tweak
bachya May 28, 2018
e18fc64
Bumping Travis and Coveralls
bachya May 29, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ omit =
homeassistant/components/raincloud.py
homeassistant/components/*/raincloud.py

homeassistant/components/rainmachine.py
homeassistant/components/rainmachine/*
homeassistant/components/*/rainmachine.py

homeassistant/components/raspihats.py
Expand Down
3 changes: 2 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ homeassistant/components/sensor/sytadin.py @gautric
homeassistant/components/sensor/tibber.py @danielhiversen
homeassistant/components/sensor/upnp.py @dgomes
homeassistant/components/sensor/waqi.py @andrey-git
homeassistant/components/switch/rainmachine.py @bachya
homeassistant/components/switch/tplink.py @rytilahti
homeassistant/components/vacuum/roomba.py @pschmitt
homeassistant/components/xiaomi_aqara.py @danielhiversen @syssi
Expand All @@ -100,6 +99,8 @@ homeassistant/components/matrix.py @tinloaf
homeassistant/components/*/matrix.py @tinloaf
homeassistant/components/qwikswitch.py @kellerza
homeassistant/components/*/qwikswitch.py @kellerza
homeassistant/components/rainmachine/* @bachya
homeassistant/components/*/rainmachine.py @bachya
homeassistant/components/*/rfxtrx.py @danielhiversen
homeassistant/components/tahoma.py @philklei
homeassistant/components/*/tahoma.py @philklei
Expand Down
102 changes: 102 additions & 0 deletions homeassistant/components/binary_sensor/rainmachine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""
This platform provides binary sensors for key RainMachine data.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.rainmachine/
"""
import logging

from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.rainmachine import (
BINARY_SENSORS, DATA_RAINMACHINE, DATA_UPDATE_TOPIC, TYPE_FREEZE,
TYPE_FREEZE_PROTECTION, TYPE_HOT_DAYS, TYPE_HOURLY, TYPE_MONTH,
TYPE_RAINDELAY, TYPE_RAINSENSOR, TYPE_WEEKDAY, RainMachineEntity)
from homeassistant.const import CONF_MONITORED_CONDITIONS
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect

DEPENDENCIES = ['rainmachine']

_LOGGER = logging.getLogger(__name__)


def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the RainMachine Switch platform."""
if discovery_info is None:
return

rainmachine = hass.data[DATA_RAINMACHINE]

binary_sensors = []
for sensor_type in discovery_info[CONF_MONITORED_CONDITIONS]:
name, icon = BINARY_SENSORS[sensor_type]
binary_sensors.append(
RainMachineBinarySensor(rainmachine, sensor_type, name, icon))

add_devices(binary_sensors, True)


class RainMachineBinarySensor(RainMachineEntity, BinarySensorDevice):
"""A sensor implementation for raincloud device."""

def __init__(self, rainmachine, sensor_type, name, icon):
"""Initialize the sensor."""
super().__init__(rainmachine)

self._icon = icon
self._name = name
self._sensor_type = sensor_type
self._state = None

@property
def icon(self) -> str:
"""Return the icon."""
return self._icon

@property
def is_on(self):
"""Return the status of the sensor."""
return self._state

@property
def should_poll(self):
"""Disable polling."""
return False

@property
def unique_id(self) -> str:
"""Return a unique, HASS-friendly identifier for this entity."""
return '{0}_{1}'.format(
self.rainmachine.device_mac.replace(':', ''), self._sensor_type)

@callback
def update_data(self):
"""Update the state."""
self.async_schedule_update_ha_state(True)

async def async_added_to_hass(self):
"""Register callbacks."""
async_dispatcher_connect(self.hass, DATA_UPDATE_TOPIC,
self.update_data)

def update(self):
"""Update the state."""
if self._sensor_type == TYPE_FREEZE:
self._state = self.rainmachine.restrictions['current']['freeze']
elif self._sensor_type == TYPE_FREEZE_PROTECTION:
self._state = self.rainmachine.restrictions['global'][
'freezeProtectEnabled']
elif self._sensor_type == TYPE_HOT_DAYS:
self._state = self.rainmachine.restrictions['global'][
'hotDaysExtraWatering']
elif self._sensor_type == TYPE_HOURLY:
self._state = self.rainmachine.restrictions['current']['hourly']
elif self._sensor_type == TYPE_MONTH:
self._state = self.rainmachine.restrictions['current']['month']
elif self._sensor_type == TYPE_RAINDELAY:
self._state = self.rainmachine.restrictions['current']['rainDelay']
elif self._sensor_type == TYPE_RAINSENSOR:
self._state = self.rainmachine.restrictions['current'][
'rainSensor']
elif self._sensor_type == TYPE_WEEKDAY:
self._state = self.rainmachine.restrictions['current']['weekDay']
132 changes: 0 additions & 132 deletions homeassistant/components/rainmachine.py

This file was deleted.

Loading