Skip to content

Commit

Permalink
bump pysolarfocus and add new sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
LavermanJJ committed Mar 1, 2024
1 parent 4596d4a commit 6914e1d
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 6 deletions.
55 changes: 55 additions & 0 deletions custom_components/solarfocus/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@
BUFFER_PREFIX,
CONF_BIOMASS_BOILER,
CONF_BUFFER,
CONF_FRESH_WATER_MODULE,
CONF_HEATING_CIRCUIT,
CONF_HEATPUMP,
CONF_PHOTOVOLTAIC,
DATA_COORDINATOR,
DOMAIN,
FRESH_WATER_MODULE_COMPONENT,
FRESH_WATER_MODULE_COMPONENT_PREFIX,
FRESH_WATER_MODULE_PREFIX,
HEAT_PUMP_COMPONENT,
HEAT_PUMP_COMPONENT_PREFIX,
HEAT_PUMP_PREFIX,
HEATING_CIRCUIT_COMPONENT,
HEATING_CIRCUIT_COMPONENT_PREFIX,
HEATING_CIRCUIT_PREFIX,
PHOTOVOLTAIC_COMPONENT,
PHOTOVOLTAIC_COMPONENT_PREFIX,
PHOTOVOLTAIC_PREFIX,
)
from .entity import (
SolarfocusEntity,
Expand Down Expand Up @@ -106,6 +114,32 @@ async def async_setup_entry(
entity = SolarfocusBinarySensorEntity(coordinator, _description)
entities.append(entity)

if config_entry.options[CONF_PHOTOVOLTAIC]:
for description in PHOTOVOLTAIC_BINARY_SENSOR_TYPES:
_description = create_description(
PHOTOVOLTAIC_PREFIX,
PHOTOVOLTAIC_COMPONENT,
PHOTOVOLTAIC_COMPONENT_PREFIX,
"",
description,
)

entity = SolarfocusBinarySensorEntity(coordinator, _description)
entities.append(entity)

if config_entry.options[CONF_FRESH_WATER_MODULE]:
for description in FRESH_WATER_MODULE_BINARY_SENSOR_TYPES:
_description = create_description(
FRESH_WATER_MODULE_PREFIX,
FRESH_WATER_MODULE_COMPONENT,
FRESH_WATER_MODULE_COMPONENT_PREFIX,
"",
description,
)

entity = SolarfocusBinarySensorEntity(coordinator, _description)
entities.append(entity)

async_add_entities(filterVersionAndSystem(config_entry, entities))


Expand Down Expand Up @@ -195,3 +229,24 @@ def is_on(self):
unsupported_systems=[Systems.THERMINATOR, Systems.VAMPAIR],
),
]

PHOTOVOLTAIC_BINARY_SENSOR_TYPES = [
SolarfocusBinarySensorEntityDescription(
key="overcharge_possible",
device_class=BinarySensorDeviceClass.POWER,
on_state="1",
),
SolarfocusBinarySensorEntityDescription(
key="overcharge_active",
device_class=BinarySensorDeviceClass.RUNNING,
on_state="1",
),
]

FRESH_WATER_MODULE_BINARY_SENSOR_TYPES = [
SolarfocusBinarySensorEntityDescription(
key="valve",
device_class=BinarySensorDeviceClass.OPENING,
on_state="1",
),
]
16 changes: 13 additions & 3 deletions custom_components/solarfocus/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

# CONF_API_VERSION
SOLARFOCUS_API_VERSIONS = [
selector.SelectOptionDict(value="23.040", label="v23.040"),
selector.SelectOptionDict(value="23.020", label="v23.020"),
selector.SelectOptionDict(value="23.010", label="v23.010"),
selector.SelectOptionDict(value="22.090", label="v22.090"),
Expand Down Expand Up @@ -228,7 +229,10 @@ async def async_step_component(
return self.async_show_form(
step_id="component", data_schema=STEP_COMP_VAMPAIR_SELECTION_SCHEMA
)
if self.data[CONF_SOLARFOCUS_SYSTEM] in [Systems.THERMINATOR, Systems.ECOTOP]:
if self.data[CONF_SOLARFOCUS_SYSTEM] in [
Systems.THERMINATOR,
Systems.ECOTOP,
]:
return self.async_show_form(
step_id="component",
data_schema=STEP_COMP_THERMINATOR_SELECTION_SCHEMA,
Expand Down Expand Up @@ -295,7 +299,10 @@ async def async_step_init(
if self.config_entry.data[CONF_SOLARFOCUS_SYSTEM] == Systems.VAMPAIR:
self.options[CONF_HEATPUMP] = user_input[CONF_HEATPUMP]
self.options[CONF_BIOMASS_BOILER] = False
elif self.config_entry.data[CONF_SOLARFOCUS_SYSTEM] in [Systems.THERMINATOR, Systems.ECOTOP]:
elif self.config_entry.data[CONF_SOLARFOCUS_SYSTEM] in [
Systems.THERMINATOR,
Systems.ECOTOP,
]:
self.options[CONF_BIOMASS_BOILER] = user_input[CONF_BIOMASS_BOILER]
self.options[CONF_HEATPUMP] = False

Expand Down Expand Up @@ -396,7 +403,10 @@ async def _show_init_form(self, user_input, errors):
}
)

elif self.config_entry.data[CONF_SOLARFOCUS_SYSTEM] in [Systems.THERMINATOR, Systems.ECOTOP]:
elif self.config_entry.data[CONF_SOLARFOCUS_SYSTEM] in [
Systems.THERMINATOR,
Systems.ECOTOP,
]:
data_schema = vol.Schema(
{
vol.Required(
Expand Down
4 changes: 2 additions & 2 deletions custom_components/solarfocus/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"integration_type": "hub",
"iot_class": "local_polling",
"issue_tracker": "https://github.com/lavermanjj/home-assistant-solarfocus/issues",
"requirements": ["pysolarfocus==4.1.0"],
"requirements": ["pysolarfocus==4.2.0"],
"ssdp": [],
"version": "4.0.1",
"version": "4.1.0",
"zeroconf": []
}
25 changes: 24 additions & 1 deletion custom_components/solarfocus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def native_value(self):
icon="mdi:format-list-bulleted",
device_class=SensorDeviceClass.ENUM,
options=list(range(0, 2)),
unsupported_systems=[Systems.VAMPAIR, Systems.ECOTOP],
unsupported_systems=[Systems.VAMPAIR, Systems.ECOTOP],
),
SolarfocusSensorEntityDescription(
key="pellet_usage_last_fill",
Expand Down Expand Up @@ -717,4 +717,27 @@ def native_value(self):
options=list(range(0, 5)),
min_required_version="23.020",
),
SolarfocusSensorEntityDescription(
key="supply_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
icon="mdi:thermometer",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
min_required_version="23.040",
),
SolarfocusSensorEntityDescription(
key="flow_rate",
native_unit_of_measurement=VOLUME_FLOW_RATE_LITER_PER_HOUR,
icon="mdi:speedometer",
state_class=SensorStateClass.MEASUREMENT,
min_required_version="23.040",
),
SolarfocusSensorEntityDescription(
key="target_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
icon="mdi:thermometer",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
min_required_version="23.040",
),
]

0 comments on commit 6914e1d

Please sign in to comment.