-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from tijsverkoyen/more-data
Add support for String inverter, EMI, Grid meter, Battery and Power Sensor
- Loading branch information
Showing
9 changed files
with
1,044 additions
and
140 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
52 changes: 52 additions & 0 deletions
52
custom_components/fusion_solar/fusion_solar/device_attribute_entity.py
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,52 @@ | ||
from homeassistant.helpers.entity import Entity, EntityCategory | ||
|
||
from .openapi.device import FusionSolarDevice | ||
from ..const import DOMAIN | ||
|
||
|
||
class FusionSolarDeviceAttributeEntity(Entity): | ||
def __init__( | ||
self, | ||
device: FusionSolarDevice, | ||
name, | ||
attribute, | ||
value | ||
): | ||
"""Initialize the entity""" | ||
self._device = device | ||
self._name = name | ||
self._attribute = attribute | ||
self._device_info = device.device_info() | ||
self._value = value | ||
|
||
@property | ||
def unique_id(self) -> str: | ||
return f'{DOMAIN}-{self._device.device_id}-{self._attribute}' | ||
|
||
@property | ||
def name(self): | ||
return f'{self._device.readable_name} - {self._name}' | ||
|
||
@property | ||
def state(self): | ||
return self._value | ||
|
||
@property | ||
def device_info(self) -> dict: | ||
return self._device_info | ||
|
||
@property | ||
def entity_category(self) -> str: | ||
return EntityCategory.DIAGNOSTIC | ||
|
||
@property | ||
def should_poll(self) -> bool: | ||
return False | ||
|
||
|
||
class FusionSolarDeviceLatitudeEntity(FusionSolarDeviceAttributeEntity): | ||
_attr_icon = 'mdi:latitude' | ||
|
||
|
||
class FusionSolarDeviceLongitudeEntity(FusionSolarDeviceAttributeEntity): | ||
_attr_icon = 'mdi:longitude' |
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
Oops, something went wrong.