Skip to content

Commit

Permalink
Merge pull request #57 from VeksKM/ids2state
Browse files Browse the repository at this point in the history
Add sensor, heaters and coolers into state attributes
  • Loading branch information
MapoDan authored Nov 9, 2022
2 parents 5d3aa00 + 90eae77 commit fcc5d7f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 15 additions & 1 deletion custom_components/programmable_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
from .const import (
VERSION,
DOMAIN,
PLATFORM
PLATFORM,
ATTR_HEATER_IDS,
ATTR_COOLER_IDS,
ATTR_SENSOR_ID
)
from .config_schema import(
CLIMATE_SCHEMA,
Expand Down Expand Up @@ -614,3 +617,14 @@ def hvac_action(self):
Need to be one of CURRENT_HVAC_*.
"""
return self._hvac_action

@property
def extra_state_attributes(self):
"""Return entity specific state attributes to be saved. """
attributes = {}

attributes[ATTR_HEATER_IDS] = self.heaters_entity_ids
attributes[ATTR_COOLER_IDS] = self.coolers_entity_ids
attributes[ATTR_SENSOR_ID] = self.sensor_entity_id

return attributes
5 changes: 5 additions & 0 deletions custom_components/programmable_thermostat/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@
INITIAL_HVAC_MODE_OPTIONS = ['', HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_OFF, HVAC_MODE_HEAT_COOL]
INITIAL_HVAC_MODE_OPTIONS_OPTFLOW = ['null', HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_OFF, HVAC_MODE_HEAT_COOL]
REGEX_STRING = r'((?P<hours>\d+?):(?=(\d+?:\d+?)))?((?P<minutes>\d+?):)?((?P<seconds>\d+?))?$'

#Attributes
ATTR_HEATER_IDS = "heater_ids"
ATTR_COOLER_IDS = "cooler_ids"
ATTR_SENSOR_ID = "sensor_id"

0 comments on commit fcc5d7f

Please sign in to comment.