Skip to content

Commit

Permalink
initial support for solar generation
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyphillips committed Mar 10, 2022
1 parent 4cb81c3 commit 77fabda
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
10 changes: 8 additions & 2 deletions custom_components/echonetlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
ENL_STATUS, ENL_BRIGHTNESS, ENL_COLOR_TEMP
]

# fix later
_0287_API_CONNECTOR_DEFAULT_FLAGS = [ENL_STATUS, 0xC0, 0xC1, 0xC2, 0xC5, 0xC6, 0xC7, 0xC8]

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entry.async_on_unload(entry.add_update_listener(update_listener))
host = None
Expand Down Expand Up @@ -188,12 +191,15 @@ def __init__(self, instance, api, entry):
# Detect HVAC - eventually we will use factory here.
self._update_flags_full_list = []
flags = []
if self._eojgc == 1 and self._eojcc == 48:
if self._eojgc == 0x01 and self._eojcc == 0x30:
_LOGGER.debug(f"Starting ECHONETLite HomeAirConditioner instance at {self._host}")
flags = HVAC_API_CONNECTOR_DEFAULT_FLAGS
elif self._eojgc == 2 and self._eojcc == 144:
elif self._eojgc == 0x02 and self._eojcc == 0x90:
_LOGGER.debug(f"Starting ECHONETLite GeneralLighting instance at {self._host}")
flags = LIGHT_API_CONNECTOR_DEFAULT_FLAGS
elif self._eojgc == 0x02 and self._eojcc == 0x87:
_LOGGER.debug(f"Starting ECHONETLite DistributionPanelMeter instance at {self._host}")
flags = _0287_API_CONNECTOR_DEFAULT_FLAGS
else:
_LOGGER.debug(f"Starting ECHONETLite Generic instance for {self._eojgc}-{self._eojcc}-{self._eojci} at {self._host}")
flags = [ENL_STATUS]
Expand Down
36 changes: 35 additions & 1 deletion custom_components/echonetlite/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Constants for the echonetlite integration."""
from homeassistant.const import CONF_ICON, CONF_TYPE, DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_ENERGY, DEVICE_CLASS_HUMIDITY
from homeassistant.const import CONF_ICON, CONF_TYPE, DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_ENERGY, DEVICE_CLASS_HUMIDITY, PERCENTAGE
from homeassistant.components.sensor import ATTR_STATE_CLASS, STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING
from pychonet.HomeAirConditioner import (
ENL_FANSPEED,
Expand Down Expand Up @@ -80,6 +80,40 @@
}
}
},
0x02: {
0x87:{
0xE0: {
CONF_ICON: "mdi:flash",
CONF_TYPE: DEVICE_CLASS_POWER,
CONF_STATE_CLASS: STATE_CLASS_MEASUREMENT
},
0xE1: {
CONF_ICON: "mdi:flash",
CONF_TYPE: DEVICE_CLASS_ENERGY,
CONF_STATE_CLASS: STATE_CLASS_TOTAL_INCREASING
},
0xE5: {
CONF_ICON: "mdi:percent",
CONF_TYPE: PERCENTAGE,
CONF_STATE_CLASS: STATE_CLASS_MEASUREMENT
},
0xE6: {
CONF_ICON: "mdi:flash",
CONF_TYPE: DEVICE_CLASS_POWER,
CONF_STATE_CLASS: STATE_CLASS_MEASUREMENT
},
0xE8: {
CONF_ICON: "mdi:flash",
CONF_TYPE: DEVICE_CLASS_POWER,
CONF_STATE_CLASS: STATE_CLASS_MEASUREMENT
},
0xE9: {
CONF_ICON: "mdi:flash",
CONF_TYPE: DEVICE_CLASS_POWER,
CONF_STATE_CLASS: STATE_CLASS_MEASUREMENT
}
}
}
'default': {
CONF_ICON: None,
CONF_TYPE: None,
Expand Down
4 changes: 2 additions & 2 deletions custom_components/echonetlite/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"config_flow": true,
"documentation": "https://www.github.com/scottyphillips/echonetlite_homeassistant",
"requirements": [
"pychonet==2.1.1",
"pychonet==2.1.6",
"aio-udp-server"
],
"dependencies": [],
"codeowners": [
"@scottyphillips"
],
"version": "3.4.1",
"version": "3.4.2",
"iot_class": "local_polling"
}
2 changes: 2 additions & 0 deletions custom_components/echonetlite/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def __init__(self, instance, op_code, attributes, name=None) -> None:
self._unit_of_measurement = POWER_WATT
elif self._sensor_attributes[CONF_TYPE] == DEVICE_CLASS_HUMIDITY:
self._unit_of_measurement = PERCENTAGE
elif self._sensor_attributes[CONF_TYPE] == PERCENTAGE:
self._unit_of_measurement = PERCENTAGE
else:
self._unit_of_measurement = None

Expand Down

0 comments on commit 77fabda

Please sign in to comment.