#NEWLINE# def setup( hass , config ) : #NEWLINE# #INDENT# 'Setup thermostats.' #NEWLINE# component = EntityComponent ( _LOGGER , DOMAIN , hass , SCAN_INTERVAL , DISCOVERY_PLATFORMS ) #NEWLINE# component . setup ( config ) #NEWLINE# descriptions = load_yaml_config_file ( os . path . join ( os . path . dirname ( __file__ ) , 'services.yaml' ) ) #NEWLINE# def away_mode_set_service( service ) : #NEWLINE# #INDENT# 'Set away mode on target thermostats.' #NEWLINE# target_thermostats = component . extract_from_service ( service ) #NEWLINE# away_mode = service . data [ ATTR_AWAY_MODE ] #NEWLINE# for thermostat in target_thermostats : #NEWLINE# #INDENT# if away_mode : #NEWLINE# #INDENT# thermostat . turn_away_mode_on ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# thermostat . turn_away_mode_off ( ) #NEWLINE# #UNINDENT# thermostat . update_ha_state ( True ) #NEWLINE# #UNINDENT# #UNINDENT# hass . services . register ( DOMAIN , SERVICE_SET_AWAY_MODE , away_mode_set_service , descriptions . get ( SERVICE_SET_AWAY_MODE ) , schema = SET_AWAY_MODE_SCHEMA ) #NEWLINE# def temperature_set_service( service ) : #NEWLINE# #INDENT# 'Set temperature on the target thermostats.' #NEWLINE# target_thermostats = component . extract_from_service ( service ) #NEWLINE# temperature = service . data [ ATTR_TEMPERATURE ] #NEWLINE# for thermostat in target_thermostats : #NEWLINE# #INDENT# thermostat . set_temperature ( convert ( temperature , hass . config . temperature_unit , thermostat . unit_of_measurement ) ) #NEWLINE# thermostat . update_ha_state ( True ) #NEWLINE# #UNINDENT# #UNINDENT# hass . services . register ( DOMAIN , SERVICE_SET_TEMPERATURE , temperature_set_service , descriptions . get ( SERVICE_SET_TEMPERATURE ) , schema = SET_TEMPERATURE_SCHEMA ) #NEWLINE# def fan_mode_set_service( service ) : #NEWLINE# #INDENT# 'Set fan mode on target thermostats.' #NEWLINE# target_thermostats = component . extract_from_service ( service ) #NEWLINE# fan_mode = service . data [ ATTR_FAN ] #NEWLINE# for thermostat in target_thermostats : #NEWLINE# #INDENT# if fan_mode : #NEWLINE# #INDENT# thermostat . turn_fan_on ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# thermostat . turn_fan_off ( ) #NEWLINE# #UNINDENT# thermostat . update_ha_state ( True ) #NEWLINE# #UNINDENT# #UNINDENT# hass . services . register ( DOMAIN , SERVICE_SET_FAN_MODE , fan_mode_set_service , descriptions . get ( SERVICE_SET_FAN_MODE ) , schema = SET_FAN_MODE_SCHEMA ) #NEWLINE# return True