Advertisement
Guest User

Untitled

a guest
Nov 7th, 2018
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. thermostat_id = data.get('thermostat')
  2. heat_state = data.get('heat_state', 'heat')
  3. idle_state = data.get('idle_state', 'off')
  4. idle_heat_temp = data.get('idle_heat_temp', 8)
  5.  
  6. if thermostat_id:
  7.     thermostat = hass.states.get(thermostat_id)
  8.     attributes = thermostat.attributes.copy()
  9.     attributes['operation_list'] = '{},{}'.format(heat_state, idle_state)
  10.     if float(attributes['temperature']) > idle_heat_temp:
  11.         state = heat_state
  12.         attributes['operation_mode'] = heat_state
  13.     else:
  14.         state = idle_state
  15.         attributes['operation_mode'] = idle_state
  16.     hass.states.set(thermostat_id, state, attributes)
  17. else:
  18.     logger.error("Wrong arguments!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement