Update Smappee integration with proper solar, voltage and reactive entities (#37407)

This commit is contained in:
bsmappee 2020-07-08 22:45:01 +02:00 committed by GitHub
parent d60c52bbc7
commit 99c815bcbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 20 deletions

View File

@ -5,7 +5,7 @@
"documentation": "https://www.home-assistant.io/integrations/smappee", "documentation": "https://www.home-assistant.io/integrations/smappee",
"dependencies": ["http"], "dependencies": ["http"],
"requirements": [ "requirements": [
"pysmappee==0.1.2" "pysmappee==0.1.4"
], ],
"codeowners": [ "codeowners": [
"@bsmappee" "@bsmappee"

View File

@ -16,13 +16,6 @@ TREND_SENSORS = {
"total_power", "total_power",
DEVICE_CLASS_POWER, DEVICE_CLASS_POWER,
], ],
"total_reactive_power": [
"Total consumption - Reactive power",
None,
POWER_WATT,
"total_reactive_power",
DEVICE_CLASS_POWER,
],
"alwayson": [ "alwayson": [
"Always on - Active power", "Always on - Active power",
None, None,
@ -59,6 +52,15 @@ TREND_SENSORS = {
None, None,
], ],
} }
REACTIVE_SENSORS = {
"total_reactive_power": [
"Total consumption - Reactive power",
None,
POWER_WATT,
"total_reactive_power",
DEVICE_CLASS_POWER,
]
}
SOLAR_SENSORS = { SOLAR_SENSORS = {
"solar_power": [ "solar_power": [
"Total production - Active power", "Total production - Active power",
@ -151,6 +153,17 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
) )
) )
if service_location.has_reactive_value:
for reactive_sensor in REACTIVE_SENSORS:
entities.append(
SmappeeSensor(
smappee_base=smappee_base,
service_location=service_location,
sensor=reactive_sensor,
attributes=REACTIVE_SENSORS[reactive_sensor],
)
)
# Add solar sensors # Add solar sensors
if service_location.has_solar_production: if service_location.has_solar_production:
for sensor in SOLAR_SENSORS: for sensor in SOLAR_SENSORS:
@ -180,17 +193,18 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
) )
) )
# Add phase- and line voltages # Add phase- and line voltages if available
for sensor_name, sensor in VOLTAGE_SENSORS.items(): if service_location.has_voltage_values:
if service_location.phase_type in sensor[5]: for sensor_name, sensor in VOLTAGE_SENSORS.items():
entities.append( if service_location.phase_type in sensor[5]:
SmappeeSensor( entities.append(
smappee_base=smappee_base, SmappeeSensor(
service_location=service_location, smappee_base=smappee_base,
sensor=sensor_name, service_location=service_location,
attributes=sensor, sensor=sensor_name,
attributes=sensor,
)
) )
)
# Add Gas and Water sensors # Add Gas and Water sensors
for sensor_id, sensor in service_location.sensors.items(): for sensor_id, sensor in service_location.sensors.items():

View File

@ -1620,7 +1620,7 @@ pysignalclirestapi==0.3.4
pysma==0.3.5 pysma==0.3.5
# homeassistant.components.smappee # homeassistant.components.smappee
pysmappee==0.1.2 pysmappee==0.1.4
# homeassistant.components.smartthings # homeassistant.components.smartthings
pysmartapp==0.3.2 pysmartapp==0.3.2

View File

@ -727,7 +727,7 @@ pysignalclirestapi==0.3.4
pysma==0.3.5 pysma==0.3.5
# homeassistant.components.smappee # homeassistant.components.smappee
pysmappee==0.1.2 pysmappee==0.1.4
# homeassistant.components.smartthings # homeassistant.components.smartthings
pysmartapp==0.3.2 pysmartapp==0.3.2