forked from jmoor3/homeassistant-components
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added fault log sensor (shows last fault message in list) - Updated lighting entity to handle color mode requirements - Code cleanup
- Loading branch information
Showing
9 changed files
with
851 additions
and
645 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"""Support for Spa Client sensors.""" | ||
# Import the device class from the component that you want to support | ||
from . import SpaClientDevice | ||
from .const import _LOGGER, DOMAIN, ICONS, FAULT_MSG, SPA | ||
from datetime import timedelta | ||
from homeassistant.components.sensor import SensorEntity | ||
|
||
SCAN_INTERVAL = timedelta(seconds=1) | ||
|
||
|
||
async def async_setup_entry(hass, config_entry, async_add_entities): | ||
"""Set up the Spa Client sensors.""" | ||
|
||
spaclient = hass.data[DOMAIN][config_entry.entry_id][SPA] | ||
entities = [] | ||
|
||
entities.append(SpaFaultLog(spaclient, config_entry)) | ||
|
||
async_add_entities(entities, True) | ||
|
||
|
||
class SpaFaultLog(SpaClientDevice, SensorEntity): | ||
"""Representation of a sensor.""" | ||
|
||
def __init__(self, spaclient, config_entry): | ||
"""Initialize the device.""" | ||
super().__init__(spaclient, config_entry) | ||
self._spaclient = spaclient | ||
self._sensor_type = None | ||
self._icon = ICONS.get('Fault Log') | ||
|
||
@property | ||
def unique_id(self) -> str: | ||
"""Return a unique ID.""" | ||
return f"{self._spaclient.get_macaddr().replace(':', '')}#fault_log" | ||
|
||
@property | ||
def device_class(self): | ||
"""Return the class of this sensor.""" | ||
return self._sensor_type | ||
|
||
@property | ||
def name(self): | ||
"""Return the name of the sensor.""" | ||
return 'Last Known Fault' | ||
|
||
@property | ||
def icon(self): | ||
"""Return the icon of the device.""" | ||
return self._icon | ||
|
||
@property | ||
def native_value(self): | ||
"""Return the state of this sensor.""" | ||
return FAULT_MSG.get(self._spaclient.get_fault_log_msg_code()) | ||
|
||
@property | ||
def available(self) -> bool: | ||
"""Return True if entity is available.""" | ||
return self._spaclient.get_gateway_status() |
Oops, something went wrong.
5187fbb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for keeping this maintained. I appreciate the addition of time sync. I haven't tested it yet but that isn't really necessary.
I would like to see ?sensors? support consumption values so that I can track energy consumption etc. Have I missed something really basic? It wouldn't surprise me that I have! Does this integration provide sufficient temporal resolution? I don't have a lot of time for unproductive/deep learning at the moment. There are more basic things I need to attend to in my system.
What I have in mind is the ability to enter a value such as Watts for each significant load segment - circulator, each pump, and heater. From there Energy should be able to track so long as on and off times are accurate to within a few seconds I think.
I will incrementally learn all 'the things' but as said, I can't build wheels at the moment.
If you want, I can open an issue but this is more of a feature request. Not sure where to do that.
Anyway. thanks again for doing this! It is really appreciated.
Anon
5187fbb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, I was thinking of the same kind of new features for this component. I don't know if it's feasable, but like you, I don't have much time for the project. I take note and start looking at this in my spare times. If you have any suggestions of components that do the same processing (manual power inputs for loads), let me know.