Skip to content

Commit

Permalink
Merge pull request #52 from claudegel/patch-aux-cycle
Browse files Browse the repository at this point in the history
add set_cycle_length
  • Loading branch information
claudegel authored Mar 21, 2022
2 parents 26ea406 + e700b84 commit 3892506
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Automations require services to be able to send commande. Ex. light.turn_on. For
- neviweb.set_setpoint_max, to set maximum setpoint temperature for thermostats.
- neviweb.set_light_away_mode, to set mode for light when occupency is set to away.
- neviweb.set_switch_away_mode, to set mode for switch when occupency is set to away.
- neviweb.set_cycle_length, to set low voltage thermostat main cycle length. Values are: "15 sec", "5 min", "10 min", "15 min", "20 min", "25 min", "30 min".
- neviweb.set_aux_cycle_length, to set low voltage thermostat auxiliary cycle length and output. Values are: "15 sec", "5 min", "10 min", "15 min", "20 min", "25 min", "30 min". To trun on/off auxiliary heating just use the button at the bottom of the thermostat card.

## Catch Éco Sinopé signal for peak period
Expand Down
2 changes: 1 addition & 1 deletion custom_components.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"neviweb": {
"version": "1.9.5",
"version": "1.9.6",
"local_location": "/custom_components/neviweb/__init__.py",
"remote_location": "https://github.com/claudegel/sinope-1/tree/master/custom_components/neviweb/__init__.py",
"visit_repo": "https://github.com/claudegel/sinope-1",
Expand Down
9 changes: 8 additions & 1 deletion custom_components/neviweb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
ATTR_AUX_CYCLE_LENGTH,
ATTR_AWAY_MODE,
ATTR_BACKLIGHT,
ATTR_CYCLE_LENGTH,
ATTR_DISPLAY_2,
ATTR_EARLY_START,
ATTR_FLOOR_MODE,
Expand All @@ -43,7 +44,7 @@
)

#REQUIREMENTS = ['PY_Sinope==0.1.5']
VERSION = '1.9.5'
VERSION = '1.9.6'

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -425,6 +426,12 @@ def set_aux_heat(self, device_id, heat, cycle, floor):
_LOGGER.debug("aux_heat.data = %s", data)
self.set_device_attributes(device_id, data)

def set_cycle_length(self, device_id, length):
"""Set low voltage thermostats main heating cycle."""
data = {ATTR_CYCLE_LENGTH: length}
_LOGGER.debug("cycle.data = %s", data)
self.set_device_attributes(device_id, data)

def set_aux_cycle_length(self, device_id, output, length):
"""Set low voltage thermostats auxiliary heating output and cycle."""
data = {ATTR_AUX_CONFIG: output, ATTR_AUX_CYCLE_LENGTH: length}
Expand Down
60 changes: 48 additions & 12 deletions custom_components/neviweb/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
SERVICE_SET_AUX_CYCLE_LENGTH,
SERVICE_SET_BACKLIGHT,
SERVICE_SET_CLIMATE_KEYPAD_LOCK,
SERVICE_SET_CYCLE_LENGTH,
SERVICE_SET_EARLY_START,
SERVICE_SET_SECOND_DISPLAY,
SERVICE_SET_SETPOINT_MAX,
Expand All @@ -120,13 +121,13 @@
PERIOD_VALUE = {"15 sec", "5 min", "10 min", "15 min", "20 min", "25 min", "30 min"}

HA_TO_NEVIWEB_PERIOD = {
"15 sec": 15,
"5 min": 300,
"10 min": 600,
"15 min": 900,
"20 min": 1200,
"25 min": 1500,
"30 min": 1800
'15 sec': 'short',
'5 min': 'long5min',
'10 min': 'long10min',
'15 min': 'long15min',
'20 min': 'long20min',
'25 min': 'long25min',
'30 min': 'long30min'
}

UPDATE_ATTRIBUTES = [
Expand Down Expand Up @@ -235,6 +236,15 @@
}
)

SET_CYCLE_LENGTH_SCHEMA = vol.Schema(
{
vol.Required(ATTR_ENTITY_ID): cv.entity_id,
vol.Required("value"): vol.All(
cv.ensure_list, [vol.In(PERIOD_VALUE)]
),
}
)

SET_AUX_CYCLE_LENGTH_SCHEMA = vol.Schema(
{
vol.Required(ATTR_ENTITY_ID): cv.entity_id,
Expand Down Expand Up @@ -368,13 +378,24 @@ def set_air_floor_mode_service(service):
thermostat.schedule_update_ha_state(True)
break

def set_cycle_length_service(service):
"""set main cycle duration for low voltage thermostats"""
entity_id = service.data[ATTR_ENTITY_ID]
value = {}
for thermostat in entities:
if thermostat.entity_id == entity_id:
value = {"id": thermostat.unique_id, "length": service.data["value"][0]}
thermostat.set_cycle_length(value)
thermostat.schedule_update_ha_state(True)
break

def set_aux_cycle_length_service(service):
"""set aux cycle duration for low voltage thermosstats"""
"""set auxiliary cycle duration for low voltage thermostats"""
entity_id = service.data[ATTR_ENTITY_ID]
value = {}
for thermostat in entities:
if thermostat.entity_id == entity_id:
value = {"id": thermostat.unique_id, "length": service.data["value"]}
value = {"id": thermostat.unique_id, "length": service.data["value"][0]}
thermostat.set_aux_cycle_length(value)
thermostat.schedule_update_ha_state(True)
break
Expand Down Expand Up @@ -442,6 +463,13 @@ def set_aux_cycle_length_service(service):
schema=SET_AIR_FLOOR_MODE_SCHEMA,
)

hass.services.async_register(
DOMAIN,
SERVICE_SET_CYCLE_LENGTH,
set_cycle_length_service,
schema=SET_CYCLE_LENGTH_SCHEMA,
)

hass.services.async_register(
DOMAIN,
SERVICE_SET_AUX_CYCLE_LENGTH,
Expand Down Expand Up @@ -717,7 +745,7 @@ def extra_state_attributes(self):
'auxiliary_load': self._aux_wattage,
'auxiliary_output_conf': self._aux_cycle_config,
'auxiliary_output_cycle': neviweb_to_ha(self._aux_cycle_length),
'cycle_length': self._cycle_length,
'cycle_length': neviweb_to_ha(self._cycle_length),
'floor_sensor_type': self._sensor_type,
'floor_setpoint': self._floor_setpoint,
'floor_temperature': self._floor_temperature,
Expand Down Expand Up @@ -952,12 +980,20 @@ def set_preset_mode(self, preset_mode):
_LOGGER.error("Unable to set preset mode: %s.", preset_mode)
self._operation_mode = preset_mode

def set_cycle_length(self, value):
"""Set main cycle length for low voltage thermostats"""
val = value["length"]
entity = value["id"]
length = [v for k, v in HA_TO_NEVIWEB_PERIOD.items() if k == val][0]
self._client.set_cycle_length(
entity, length)
self._cycle_length = length

def set_aux_cycle_length(self, value):
"""Set auxiliary cycle length for low voltage thermostats"""
val = value["length"]
entity = value["id"]
if val in HA_TO_NEVIWEB_PERIOD:
length = HA_TO_NEVIWEB_PERIOD[val]
length = [v for k, v in HA_TO_NEVIWEB_PERIOD.items() if k == val][0]
if length == "short":
output = "shortCycle"
else:
Expand Down
1 change: 1 addition & 0 deletions custom_components/neviweb/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@
SERVICE_SET_SWITCH_AWAY_MODE = "set_switch_away_mode"
SERVICE_SET_AIR_FLOOR_MODE = "set_air_floor_mode"
SERVICE_SET_AUX_CYCLE_LENGTH = "set_aux_cycle_length"
SERVICE_SET_CYCLE_LENGTH = "set_cycle_length"
2 changes: 1 addition & 1 deletion custom_components/neviweb/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"dependencies": [],
"codeowners": ["@claudegel"],
"requirements": [],
"version": "1.9.5"
"version": "1.9.6"
}
10 changes: 10 additions & 0 deletions custom_components/neviweb/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,13 @@ set_aux_cycle_length:
value:
description: cycle lencht in minutes. Accepted values are "15 sec", "5 min", "10 min", "15 min", "20 min", "25 min", "30 min".
example: "10 min"

set_cycle_length:
description: Set low voltage thermostats main cycle length in minutes.
fields:
entity_id:
description: Name(s) of neviweb thermostat.
example: "climate.neviweb_climate_kitchen"
value:
description: cycle lencht in minutes. Accepted values are "15 sec", "5 min", "10 min", "15 min", "20 min", "25 min", "30 min".
example: "10 min"

0 comments on commit 3892506

Please sign in to comment.