def notify(self, hass, message, person='*'): msg = message if person == 'danil': msg = "Данил, " + msg elif person == 'sveta': msg = "Света, " + msg hass.log('notifying over alice person {} with message: {}'.format( target, message)) self.say(hass, msg)
def update_setpoints(self, hass, mode, dt_override=None, force=False): if mode is Mode.Off: return setpoint = self.eval_setpoint(mode, hass, dt_override) hass.log("Evaluated setpoint for '{self.name}' to '{setpoint}'".format( **locals())) self.set_setpoint_sensor(hass, setpoint) for tht in self.thermostats: tht.set_setpoint(hass, setpoint, force=force)
def notify(self, hass, message, person='*'): target = self.target_default if person == 'danil': target = self.target_danil elif person == 'sveta': target = self.target_sveta hass.log('notifying over telegram person {} with message: {}'.format( target, message)) hass.notify(message, name=target)
def publish(self, hass, setpoint): if self.last_setpoint is None or not math.isclose( float(self.last_setpoint), float(setpoint)): uom = self.attributes.get("unit_of_measurement") hass.log( "Setting sensor '{self.name}' to targt temperature '{setpoint} {uom}'" .format(**locals())) hass.set_state(entity_id=self.name, state=setpoint, attributes=self.attributes) self.last_setpoint = float(setpoint)
def set_setpoint(self, hass, setpoint, force=False): # Thermostat force overrides global force (if any) _force = self.force if self.force is not None else force curval = hass.get_state(entity=self.name, attribute="temperature") offsetted_sp = setpoint + self.offset range_sp = min(max(MIN_TEMP, int(offsetted_sp + 0.5)), MAX_TEMP) # Min, Max + Rounding if _force or not math.isclose(float(curval), float(range_sp)): hass.log( "Calling climate/set_temperature for '{self.name}' with setpoint " "'{range_sp}' (offset='{self.offset}')".format(**locals())) hass.call_service("climate/set_temperature", entity_id=self.name, temperature=range_sp)
def say(self, hass, message): hass.log('message = {}'.format(message)) hass.call_service('media_player/play_media', entity_id=self.alice, media_content_type='text', media_content_id=message)
def notify(self, hass, message, person='*'): hass.log('notifying person {} with message: {}'.format( person, message))