Update services.yaml for nuheat (#29133)

* update services.yaml for nuheat

* update tests

* black formatting
This commit is contained in:
Raman Gupta 2019-11-27 09:20:40 -05:00 committed by Franck Nijhof
parent fdf0793fdd
commit ef21fd2536
4 changed files with 19 additions and 16 deletions

View file

@ -9,6 +9,7 @@ set_aux_heat:
aux_heat: aux_heat:
description: New value of axillary heater. description: New value of axillary heater.
example: true example: true
set_preset_mode: set_preset_mode:
description: Set preset mode for climate device. description: Set preset mode for climate device.
fields: fields:
@ -18,6 +19,7 @@ set_preset_mode:
preset_mode: preset_mode:
description: New value of preset mode description: New value of preset mode
example: 'away' example: 'away'
set_temperature: set_temperature:
description: Set target temperature of climate device. description: Set target temperature of climate device.
fields: fields:
@ -36,6 +38,7 @@ set_temperature:
hvac_mode: hvac_mode:
description: HVAC operation mode to set temperature to. description: HVAC operation mode to set temperature to.
example: 'heat' example: 'heat'
set_humidity: set_humidity:
description: Set target humidity of climate device. description: Set target humidity of climate device.
fields: fields:
@ -45,6 +48,7 @@ set_humidity:
humidity: humidity:
description: New target humidity for climate device. description: New target humidity for climate device.
example: 60 example: 60
set_fan_mode: set_fan_mode:
description: Set fan operation for climate device. description: Set fan operation for climate device.
fields: fields:
@ -54,6 +58,7 @@ set_fan_mode:
fan_mode: fan_mode:
description: New value of fan mode. description: New value of fan mode.
example: On Low example: On Low
set_hvac_mode: set_hvac_mode:
description: Set HVAC operation mode for climate device. description: Set HVAC operation mode for climate device.
fields: fields:
@ -63,6 +68,7 @@ set_hvac_mode:
hvac_mode: hvac_mode:
description: New value of operation mode. description: New value of operation mode.
example: heat example: heat
set_swing_mode: set_swing_mode:
description: Set swing operation for climate device. description: Set swing operation for climate device.
fields: fields:
@ -72,13 +78,6 @@ set_swing_mode:
swing_mode: swing_mode:
description: New value of swing mode. description: New value of swing mode.
nuheat_resume_program:
description: Resume the programmed schedule.
fields:
entity_id:
description: Name(s) of entities to change.
example: 'climate.kitchen'
turn_on: turn_on:
description: Turn climate device on. description: Turn climate device on.
fields: fields:

View file

@ -22,7 +22,7 @@ from homeassistant.const import (
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle from homeassistant.util import Throttle
from . import DOMAIN as NUHEAT_DOMAIN from . import DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -52,7 +52,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return return
temperature_unit = hass.config.units.temperature_unit temperature_unit = hass.config.units.temperature_unit
api, serial_numbers = hass.data[NUHEAT_DOMAIN] api, serial_numbers = hass.data[DOMAIN]
thermostats = [ thermostats = [
NuHeatThermostat(api, serial_number, temperature_unit) NuHeatThermostat(api, serial_number, temperature_unit)
for serial_number in serial_numbers for serial_number in serial_numbers
@ -75,7 +75,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
thermostat.schedule_update_ha_state(True) thermostat.schedule_update_ha_state(True)
hass.services.register( hass.services.register(
NUHEAT_DOMAIN, DOMAIN,
SERVICE_RESUME_PROGRAM, SERVICE_RESUME_PROGRAM,
resume_program_set_service, resume_program_set_service,
schema=RESUME_PROGRAM_SCHEMA, schema=RESUME_PROGRAM_SCHEMA,

View file

@ -0,0 +1,6 @@
resume_program:
description: Resume the programmed schedule.
fields:
entity_id:
description: Name(s) of entities to change.
example: 'climate.kitchen'

View file

@ -67,7 +67,7 @@ class TestNuHeat(unittest.TestCase):
thermostat = mocked_thermostat(self.api, "12345", "F") thermostat = mocked_thermostat(self.api, "12345", "F")
thermostats = [thermostat] thermostats = [thermostat]
self.hass.data[nuheat.NUHEAT_DOMAIN] = (self.api, ["12345"]) self.hass.data[nuheat.DOMAIN] = (self.api, ["12345"])
config = {} config = {}
add_entities = Mock() add_entities = Mock()
@ -85,12 +85,12 @@ class TestNuHeat(unittest.TestCase):
thermostat.schedule_update_ha_state = Mock() thermostat.schedule_update_ha_state = Mock()
thermostat.entity_id = "climate.master_bathroom" thermostat.entity_id = "climate.master_bathroom"
self.hass.data[nuheat.NUHEAT_DOMAIN] = (self.api, ["12345"]) self.hass.data[nuheat.DOMAIN] = (self.api, ["12345"])
nuheat.setup_platform(self.hass, {}, Mock(), {}) nuheat.setup_platform(self.hass, {}, Mock(), {})
# Explicit entity # Explicit entity
self.hass.services.call( self.hass.services.call(
nuheat.NUHEAT_DOMAIN, nuheat.DOMAIN,
nuheat.SERVICE_RESUME_PROGRAM, nuheat.SERVICE_RESUME_PROGRAM,
{"entity_id": "climate.master_bathroom"}, {"entity_id": "climate.master_bathroom"},
True, True,
@ -103,9 +103,7 @@ class TestNuHeat(unittest.TestCase):
thermostat.schedule_update_ha_state.reset_mock() thermostat.schedule_update_ha_state.reset_mock()
# All entities # All entities
self.hass.services.call( self.hass.services.call(nuheat.DOMAIN, nuheat.SERVICE_RESUME_PROGRAM, {}, True)
nuheat.NUHEAT_DOMAIN, nuheat.SERVICE_RESUME_PROGRAM, {}, True
)
thermostat.resume_program.assert_called_with() thermostat.resume_program.assert_called_with()
thermostat.schedule_update_ha_state.assert_called_with(True) thermostat.schedule_update_ha_state.assert_called_with(True)