mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 18:48:22 +00:00
Fixed some markup and removed not yet needed class
Fixed issues during hound run (markup) and a class which is obsolete
This commit is contained in:
parent
c4f4e492e5
commit
6c6ed29329
@ -28,16 +28,18 @@ def setup(hass, config):
|
|||||||
from pyrainbird import RainbirdController
|
from pyrainbird import RainbirdController
|
||||||
|
|
||||||
controller = RainbirdController(_LOGGER)
|
controller = RainbirdController(_LOGGER)
|
||||||
controller.setConfig(server,password)
|
controller.setConfig(server, password)
|
||||||
_LOGGER.info("Rainbird Controller setup to " + str(server))
|
_LOGGER.info("Rainbird Controller setup to " + str(server))
|
||||||
|
|
||||||
def startirrigation(call):
|
def startirrigation(call):
|
||||||
station_id=call.data.get('station')
|
station_id = call.data.get('station')
|
||||||
duration=call.data.get('duration')
|
duration = call.data.get('duration')
|
||||||
_LOGGER.info("Requesting irrigation for " + str(station_id) + " duration " + str(duration))
|
_LOGGER.info("Requesting irrigation for " +\
|
||||||
result = controller.startIrrigation(station_id,duration)
|
str(station_id) + " duration " + str(duration))
|
||||||
|
result = controller.startIrrigation(station_id, duration)
|
||||||
if (result == 1):
|
if (result == 1):
|
||||||
_LOGGER.info("Irrigation started on "+str(station_id)+ " for " + str(duration))
|
_LOGGER.info("Irrigation started on "+str(station_id)+\
|
||||||
|
" for " + str(duration))
|
||||||
elif (result == 0):
|
elif (result == 0):
|
||||||
_LOGGER.error("Error sending request")
|
_LOGGER.error("Error sending request")
|
||||||
else:
|
else:
|
||||||
@ -48,7 +50,7 @@ def setup(hass, config):
|
|||||||
result = controller.stopIrrigation()
|
result = controller.stopIrrigation()
|
||||||
if (result == 1):
|
if (result == 1):
|
||||||
_LOGGER.info("Stopped irrigation")
|
_LOGGER.info("Stopped irrigation")
|
||||||
print ("Success")
|
print("Success")
|
||||||
elif (result == 0):
|
elif (result == 0):
|
||||||
_LOGGER.error("Error sending request")
|
_LOGGER.error("Error sending request")
|
||||||
else:
|
else:
|
||||||
@ -56,7 +58,7 @@ def setup(hass, config):
|
|||||||
|
|
||||||
def getirrigation():
|
def getirrigation():
|
||||||
_LOGGER.info("Request irrigation state")
|
_LOGGER.info("Request irrigation state")
|
||||||
result=controller.currentIrrigation()
|
result = controller.currentIrrigation()
|
||||||
if (result < 0):
|
if (result < 0):
|
||||||
_LOGGER.error("Error sending request")
|
_LOGGER.error("Error sending request")
|
||||||
return -1
|
return -1
|
||||||
@ -68,38 +70,11 @@ def setup(hass, config):
|
|||||||
hass.services.register(DOMAIN, 'start_irrigation', startirrigation)
|
hass.services.register(DOMAIN, 'start_irrigation', startirrigation)
|
||||||
hass.services.register(DOMAIN, 'stop_irrigation', stopirrigation)
|
hass.services.register(DOMAIN, 'stop_irrigation', stopirrigation)
|
||||||
|
|
||||||
helpers.event.track_time_change(hass, lambda _: hass.states.set(STATE_VAR, getirrigation()), year=None, month=None, day=None, hour=None, minute=None, second=[00,30])
|
helpers.event.track_time_change(hass, \
|
||||||
|
lambda _: hass.states.set(STATE_VAR, getirrigation()), \
|
||||||
|
year=None, month=None, day=None, hour=None, minute=None, second=[00,30])
|
||||||
|
|
||||||
|
|
||||||
_LOGGER.info("Initialized Rainbird Controller")
|
_LOGGER.info("Initialized Rainbird Controller")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class Rainbird(Entity):
|
|
||||||
"""The base class for raibird entities."""
|
|
||||||
|
|
||||||
def __init__(self,hass,stationid,name):
|
|
||||||
self._id=stationid
|
|
||||||
self._name=name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
|
||||||
def state(self):
|
|
||||||
return self_state
|
|
||||||
|
|
||||||
def name(self):
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
def id(self):
|
|
||||||
return self._id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def state_attributes(self):
|
|
||||||
attr = {
|
|
||||||
'zone_id': self.stationid,
|
|
||||||
}
|
|
||||||
|
|
||||||
return attr
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user