2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

vitoconnect: errorhandling improved and reading for fuelcell added

git-svn-id: https://svn.fhem.de/fhem/trunk@22318 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
andreas13 2020-07-01 15:54:56 +00:00
parent a8f192a572
commit b95f566a55

View File

@ -165,9 +165,14 @@
# Fehlerbehandlung verbessert
# nur noch einloggen, wenn nötig (Token läuft nach 1h aus.)
#
# 2020-06-25 Fehlerbehandlung für API (statusCode 401 (UNAUTHORIZED), 404 (DEVICE_NOT_FOUND)
# und 429 (RATE_LIMIT_EXCEEDED) und 502 (DEVICE_COMMUNICATION_ERROR)
# Neue Readings für Vitodens 200-W B2HF-19 und Brennstoffzelle von Viessmann (PA2)
# Information aus dem GW auslesen (Attribut "vitoconnect_gw_readings" auf "1" setzen;
# noch unvollständig!)
#
#
# ToDo: timeout konfigurierbar machen
# "set"s für Schedules zum Steuern der Heizung implementieren
# Attribute implementieren und dokumentieren
# mapping der Readings optional machen
# Mehrsprachigkeit
@ -206,6 +211,8 @@ my $RequestList = {
"heating.boiler.temperature.value" => "Kessel_Solltemperatur",
"heating.boiler.sensors.temperature.commonSupply.status" =>
"Kessel_Common_Supply",
"heating.boiler.sensors.temperature.commonSupply.unit" =>
"Kessel_Common_Supply_Temperatur/Einheit",
"heating.boiler.sensors.temperature.commonSupply.value" =>
"Kessel_Common_Supply_Temperatur",
"heating.boiler.sensors.temperature.main.status" => "Kessel_Status",
@ -268,6 +275,14 @@ my $RequestList = {
"heating.circuits.0.operating.programs.external.temperature" =>
"HK1-External_Temperatur",
"heating.circuits.0.operating.programs.fixed.active" => "HK1-Fixed_aktiv",
"heating.circuits.0.operating.programs.forcedLastFromSchedule.active" =>
"HK1-forcedLastFromSchedule_aktiv",
"heating.circuits.0.operating.programs.holidayAtHome.active" =>
"HK1-HolidayAtHome_aktiv",
"heating.circuits.0.operating.programs.holidayAtHome.end" =>
"HK1-HolidayAtHome_Ende",
"heating.circuits.0.operating.programs.holidayAtHome.start" =>
"HK1-HolidayAtHome_Start",
"heating.circuits.0.operating.programs.holiday.active" =>
"HK1-Urlaub_aktiv",
"heating.circuits.0.operating.programs.holiday.start" => "HK1-Urlaub_Start",
@ -280,8 +295,11 @@ my $RequestList = {
"HK1-Solltemperatur_reduziert_aktiv",
"heating.circuits.0.operating.programs.reduced.temperature" =>
"HK1-Solltemperatur_reduziert",
"heating.circuits.0.operating.programs.summerEco.active" =>
"HK1-Solltemperatur_SummerEco_aktiv",
"heating.circuits.0.operating.programs.standby.active" =>
"HK1-Standby_aktiv",
"heating.circuits.0.zone.mode.active" => "HK1-ZoneMode_aktive",
"heating.circuits.0.sensors.temperature.room.status" => "HK1-Raum_Status",
"heating.circuits.0.sensors.temperature.room.value" =>
"HK1-Raum_Temperatur",
@ -291,6 +309,7 @@ my $RequestList = {
"HK1-Vorlauftemperatur/Einheit",
"heating.circuits.0.sensors.temperature.supply.value" =>
"HK1-Vorlauftemperatur",
"heating.circuits.0.zone.mode.active" => "HK1-ZoneMode_aktive",
"heating.circuits.1.active" => "HK2-aktiv",
"heating.circuits.1.circulation.pump.status" => "HK2-Zirkulationspumpe",
@ -337,6 +356,14 @@ my $RequestList = {
"heating.circuits.1.operating.programs.external.temperature" =>
"HK2-External_Temperatur",
"heating.circuits.1.operating.programs.fixed.active" => "HK2-Fixed_aktiv",
"heating.circuits.1.operating.programs.forcedLastFromSchedule.active" =>
"HK2-forcedLastFromSchedule_aktiv",
"heating.circuits.1.operating.programs.holidayAtHome.active" =>
"HK2-HolidayAtHome_aktiv",
"heating.circuits.1.operating.programs.holidayAtHome.end" =>
"HK2-HolidayAtHome_Ende",
"heating.circuits.1.operating.programs.holidayAtHome.start" =>
"HK2-HolidayAtHome_Start",
"heating.circuits.1.operating.programs.holiday.active" =>
"HK2-Urlaub_aktiv",
"heating.circuits.1.operating.programs.holiday.start" => "HK2-Urlaub_Start",
@ -349,6 +376,8 @@ my $RequestList = {
"HK2-Solltemperatur_reduziert_aktiv",
"heating.circuits.1.operating.programs.reduced.temperature" =>
"HK2-Solltemperatur_reduziert",
"heating.circuits.1.operating.programs.summerEco.active" =>
"HK2-Solltemperatur_SummerEco_aktiv",
"heating.circuits.1.operating.programs.standby.active" =>
"HK2-Standby_aktiv",
"heating.circuits.1.sensors.temperature.room.status" => "HK2-Raum_Status",
@ -360,6 +389,7 @@ my $RequestList = {
"HK2-Vorlauftemperatur/Einheit",
"heating.circuits.1.sensors.temperature.supply.value" =>
"HK2-Vorlauftemperatur",
"heating.circuits.1.zone.mode.active" => "HK2-ZoneMode_aktive",
"heating.circuits.2.active" => "HK3-aktiv",
"heating.circuits.2.circulation.pump.status" => "HK3-Zirkulationspumpe",
@ -406,6 +436,14 @@ my $RequestList = {
"heating.circuits.2.operating.programs.external.temperature" =>
"HK3-External_Temperatur",
"heating.circuits.2.operating.programs.fixed.active" => "HK3-Fixed_aktiv",
"heating.circuits.2.operating.programs.forcedLastFromSchedule.active" =>
"HK3-forcedLastFromSchedule_aktiv",
"heating.circuits.2.operating.programs.holidayAtHome.active" =>
"HK3-HolidayAtHome_aktiv",
"heating.circuits.2.operating.programs.holidayAtHome.end" =>
"HK3-HolidayAtHome_Ende",
"heating.circuits.2.operating.programs.holidayAtHome.start" =>
"HK3-HolidayAtHome_Start",
"heating.circuits.2.operating.programs.holiday.active" =>
"HK3-Urlaub_aktiv",
"heating.circuits.2.operating.programs.holiday.start" => "HK3-Urlaub_Start",
@ -418,6 +456,8 @@ my $RequestList = {
"HK3-Solltemperatur_reduziert_aktiv",
"heating.circuits.2.operating.programs.reduced.temperature" =>
"HK3-Solltemperatur_reduziert",
"heating.circuits.2.operating.programs.summerEco.active" =>
"HK3-Solltemperatur_SummerEco_aktiv",
"heating.circuits.2.operating.programs.standby.active" =>
"HK3-Standby_aktiv",
"heating.circuits.2.sensors.temperature.room.status" => "HK3-Raum_Status",
@ -429,9 +469,17 @@ my $RequestList = {
"HK3-Vorlauftemperatur/Einheit",
"heating.circuits.2.sensors.temperature.supply.value" =>
"HK3-Vorlauftemperatur",
"heating.circuits.2.zone.mode.active" => "HK2-ZoneMode_aktive",
"heating.circuits.3.geofencing.active" => "HK4-Geofencing",
"heating.circuits.3.geofencing.status" => "HK4-Geofencing_Status",
"heating.circuits.3.operating.programs.summerEco.active" =>
"HK4-Solltemperatur_SummerEco_aktiv",
"heating.circuits.3.zone.mode.active" => "HK4-ZoneMode_aktive",
"heating.compressor.active" => "Kompressor_aktiv",
"heating.configuration.multiFamilyHouse.active" => "Mehrfamilenhaus_aktiv",
"heating.configuration.regulation.mode" => "Regulationmode",
"heating.controller.serial.value" => "Controller_Seriennummer",
"heating.device.time.offset.value" => "Device_Time_Offset",
"heating.dhw.active" => "WW-aktiv",
@ -471,32 +519,171 @@ my $RequestList = {
"heating.errors.active.entries" => "Fehlereintraege_aktive",
"heating.errors.history.entries" => "Fehlereintraege_Historie",
"heating.gas.consumption.dhw.day" => "Gasverbrauch_WW/Tag",
"heating.gas.consumption.dhw.week" => "Gasverbrauch_WW/Woche",
"heating.gas.consumption.dhw.month" => "Gasverbrauch_WW/Monat",
"heating.gas.consumption.dhw.year" => "Gasverbrauch_WW/Jahr",
"heating.gas.consumption.dhw.unit" => "Gasverbrauch_WW/Einheit",
"heating.flue.sensors.temperature.main.status" => "Abgassensor_Status",
"heating.flue.sensors.temperature.main.unit" =>
"Abgassensor_Temperatur/Einheit",
"heating.flue.sensors.temperature.main.value" => "Abgassensor_Temperatur",
"heating.fuelCell.operating.modes.active.value" => "Brennstoffzelle_Mode",
"heating.fuelCell.operating.modes.ecological.active" =>
"Brennstoffzelle_Mode_Ecological",
"heating.fuelCell.operating.modes.economical.active" =>
"Brennstoffzelle_Mode_Economical",
"heating.fuelCell.operating.modes.heatControlled.active" =>
"Brennstoffzelle_wärmegesteuert",
"heating.fuelCell.operating.modes.maintenance.active" =>
"Brennstoffzelle_Wartung",
"heating.fuelCell.operating.modes.standby.active" =>
"Brennstoffzelle_Standby",
"heating.fuelCell.operating.phase.value" => "Brennstoffzelle_Phase",
"heating.fuelCell.power.production.day" =>
"Brennstoffzelle_Stromproduktion/Tag",
"heating.fuelCell.power.production.month" =>
"Brennstoffzelle_Stromproduktion/Monat",
"heating.fuelCell.power.production.unit" =>
"Brennstoffzelle_Stromproduktion/Einheit",
"heating.fuelCell.power.production.week" =>
"Brennstoffzelle_Stromproduktion/Woche",
"heating.fuelCell.power.production.year" =>
"Brennstoffzelle_Stromproduktion/Jahr",
"heating.fuelCell.sensors.temperature.return.status" =>
"Brennstoffzelle_Temperatur_Rücklauf_Status",
"heating.fuelCell.sensors.temperature.return.unit" =>
"Brennstoffzelle_Temperatur_Rücklauf/Einheit",
"heating.fuelCell.sensors.temperature.return.value" =>
"Brennstoffzelle_Temperatur_Rücklauf",
"heating.fuelCell.sensors.temperature.supply.status" =>
"Brennstoffzelle_Temperatur_Vorlauf_Status",
"heating.fuelCell.sensors.temperature.supply.unit" =>
"Brennstoffzelle_Temperatur_Vorlauf/Einheit",
"heating.fuelCell.sensors.temperature.supply.value" =>
"Brennstoffzelle_Temperatur_Vorlauf",
"heating.fuelCell.statistics.availabilityRate" =>
"Brennstoffzelle_Statistic_Verfügbarkeit",
"heating.fuelCell.statistics.insertions" =>
"Brennstoffzelle_Statistic_Einschub",
"heating.fuelCell.statistics.operationHours" =>
"Brennstoffzelle_Statistic_Bestriebsstunden",
"heating.fuelCell.statistics.productionHours" =>
"Brennstoffzelle_Statistic_Produktionsstunden",
"heating.fuelCell.statistics.productionStarts" =>
"Brennstoffzelle_Statistic_Produktionsstarts",
"heating.gas.consumption.dhw.day" => "Gasverbrauch_WW/Tag",
"heating.gas.consumption.dhw.week" => "Gasverbrauch_WW/Woche",
"heating.gas.consumption.dhw.month" => "Gasverbrauch_WW/Monat",
"heating.gas.consumption.dhw.year" => "Gasverbrauch_WW/Jahr",
"heating.gas.consumption.dhw.unit" => "Gasverbrauch_WW/Einheit",
"heating.gas.consumption.heating.day" => "Gasverbrauch_Heizung/Tag",
"heating.gas.consumption.heating.week" => "Gasverbrauch_Heizung/Woche",
"heating.gas.consumption.heating.month" => "Gasverbrauch_Heizung/Monat",
"heating.gas.consumption.heating.year" => "Gasverbrauch_Heizung/Jahr",
"heating.gas.consumption.heating.unit" => "Gasverbrauch_Heizung/Einheit",
"heating.gas.consumption.total.day" => "Gasverbrauch_Total/Tag",
"heating.gas.consumption.total.month" => "Gasverbrauch_Total/Woche",
"heating.gas.consumption.total.unit" => "Gasverbrauch_Total/Einheit",
"heating.gas.consumption.total.week" => "Gasverbrauch_Total/Woche",
"heating.gas.consumption.total.year" => "Gasverbrauch_Total/Jahr",
"heating.gas.consumption.fuelCell.day" =>
"Gasverbrauch_Brennstoffzelle/Tag",
"heating.gas.consumption.fuelCell.week" =>
"Gasverbrauch_Brennstoffzelle/Woche",
"heating.gas.consumption.fuelCell.month" =>
"Gasverbrauch_Brennstoffzelle/Monat",
"heating.gas.consumption.fuelCell.year" =>
"Gasverbrauch_Brennstoffzelle/Jahr",
"heating.gas.consumption.fuelCell.unit" =>
"Gasverbrauch_Brennstoffzelle/Einheit",
"heating.heat.production.day" => "Wärmeproduktion/Tag",
"heating.heat.production.month" => "Wärmeproduktion/Woche",
"heating.heat.production.unit" => "Wärmeproduktion/Einheit",
"heating.heat.production.week" => "Wärmeproduktion/Woche",
"heating.heat.production.year" => "Wärmeproduktion/Jahr",
"heating.operating.programs.holiday.active" => "Urlaub_aktiv",
"heating.operating.programs.holiday.end" => "Urlaub_Ende",
"heating.operating.programs.holiday.start" => "Urlaub_Start",
"heating.power.consumption.day" => "Stromverbrauch/Tag",
"heating.power.consumption.month" => "Stromverbrauch/Monat",
"heating.power.consumption.week" => "Stromverbrauch/Woche",
"heating.power.consumption.year" => "Stromverbrauch/Jahr",
"heating.power.consumption.unit" => "Stromverbrauch/Einheit",
"heating.operating.programs.holidayAtHome.active" => "holidayAtHome_aktiv",
"heating.operating.programs.holidayAtHome.end" => "holidayAtHome_Ende",
"heating.operating.programs.holidayAtHome.start" => "holidayAtHome_Start",
"heating.power.consumption.day" => "Stromverbrauch/Tag",
"heating.power.consumption.month" => "Stromverbrauch/Monat",
"heating.power.consumption.week" => "Stromverbrauch/Woche",
"heating.power.consumption.year" => "Stromverbrauch/Jahr",
"heating.power.consumption.unit" => "Stromverbrauch/Einheit",
"heating.power.consumption.dhw.day" => "Stromverbrauch_WW/Tag",
"heating.power.consumption.dhw.month" => "Stromverbrauch_WW/Monat",
"heating.power.consumption.dhw.week" => "Stromverbrauch_WW/Woche",
"heating.power.consumption.dhw.year" => "Stromverbrauch_WW/Jahr",
"heating.power.consumption.dhw.unit" => "Stromverbrauch_WW/Einheit",
"heating.power.consumption.heating.day" => "Stromverbrauch_Heizung/Tag",
"heating.power.consumption.heating.month" => "Stromverbrauch_Heizung/Monat",
"heating.power.consumption.heating.week" => "Stromverbrauch_Heizung/Woche",
"heating.power.consumption.heating.year" => "Stromverbrauch_Heizung/Jahr",
"heating.power.consumption.heating.unit" =>
"Stromverbrauch_Heizung/Einheit",
"heating.power.consumption.total.day" => "Stromverbrauch_Total/Tag",
"heating.power.consumption.total.month" => "Stromverbrauch_Total/Monat",
"heating.power.consumption.total.week" => "Stromverbrauch_Total/Woche",
"heating.power.consumption.total.year" => "Stromverbrauch_Total/Jahr",
"heating.power.consumption.total.unit" => "Stromverbrauch_Total/Einheit",
"heating.power.production.day" => "Stromproduktion_Total/Tag",
"heating.power.production.demandCoverage.current.unit" =>
"Stromproduktion_Bedarfsabdeckung/Einheit",
"heating.power.production.demandCoverage.current.value" =>
"Stromproduktion_Bedarfsabdeckung/Tag",
"heating.power.production.demandCoverage.total.day" =>
"Stromproduktion_Bedarfsabdeckung/Tag",
"heating.power.production.demandCoverage.total.month" =>
"Stromproduktion_Bedarfsabdeckung/Tag",
"heating.power.production.demandCoverage.total.unit" =>
"Stromproduktion_Bedarfsabdeckung/Tag",
"heating.power.production.demandCoverage.total.week" =>
"Stromproduktion_Bedarfsabdeckung/Tag",
"heating.power.production.demandCoverage.total.year" =>
"Stromproduktion_Bedarfsabdeckung/Tag",
"heating.power.production.month" => "Stromproduktion_Total/Monat",
"heating.power.production.productionCoverage.current.unit" =>
"Stromproduktion_Produktionsabdeckung/Einheit",
"heating.power.production.productionCoverage.current.value" =>
"Stromproduktion_Produktionsabdeckung",
"heating.power.production.productionCoverage.total.day" =>
"Stromproduktion_Produktionsabdeckung_Total/Tag",
"heating.power.production.productionCoverage.total.month" =>
"Stromproduktion_Produktionsabdeckung_Total/Monat",
"heating.power.production.productionCoverage.total.unit" =>
"Stromproduktion_Produktionsabdeckung_Total/Einheit",
"heating.power.production.productionCoverage.total.week" =>
"Stromproduktion_Produktionsabdeckung_Total/Woche",
"heating.power.production.productionCoverage.total.year" =>
"Stromproduktion_Produktionsabdeckung_Total/Jahr",
"heating.power.production.unit" => "Stromproduktion_Total/Einheit",
"heating.power.production.week" => "Stromproduktion_Total/Woche",
"heating.power.production.year" => "Stromproduktion_Total/Jahr",
"heating.power.purchase.current.unit" => "Stromkauf/Einheit",
"heating.power.purchase.current.value" => "Stromkauf",
"heating.power.sold.current.unit" => "Stromverkauf/Einheit",
"heating.power.sold.current.value" => "Stromverkauf",
"heating.power.sold.day" => "Stromverkauf/Tag",
"heating.power.sold.month" => "Stromverkauf/Monat",
"heating.power.sold.unit" => "Stromverkauf/Einheit",
"heating.power.sold.week" => "Stromverkauf/Woche",
"heating.power.sold.year" => "Stromverkauf/Jahr",
"heating.sensors.pressure.supply.status" => "Drucksensor_Vorlauf_Status",
"heating.sensors.pressure.supply.unit" => "Drucksensor_Vorlauf/Einheit",
"heating.sensors.pressure.supply.value" => "Drucksensor_Vorlauf",
"heating.sensors.temperature.outside.status" => "Aussen_Status",
"heating.sensors.temperature.outside.statusWired" => "Aussen_StatusWired",
"heating.sensors.temperature.outside.statusWireless" =>
@ -566,6 +753,7 @@ sub vitoconnect_Initialize {
. "Vitoligno_300-C,Vitoligno_200-S,Vitoligno_300-P_mit_Vitotronic_200_(FO1),Vitoligno_250-S,"
. "Vitoligno_300-S "
. "vitoconnect_raw_readings:0,1 "
. "vitoconnect_gw_readings:0,1 "
. "vitoconnect_actions_active:0,1 "
. $readingFnAttributes;
return;
@ -637,7 +825,7 @@ sub vitoconnect_Set {
}
elsif ( $opt eq "HK1-Heizkurve-Niveau" ) {
my $slope = ReadingsVal( $name, "HK1-Heizkurve-Steigung", "" );
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.0.heating.curve/setCurve",
"{\"shift\":$args[0],\"slope\":$slope}",
@ -647,7 +835,7 @@ sub vitoconnect_Set {
}
elsif ( $opt eq "HK2-Heizkurve-Niveau" ) {
my $slope = ReadingsVal( $name, "HK2-Heizkurve-Steigung", "" );
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.1.heating.curve/setCurve",
"{\"shift\":$args[0],\"slope\":$slope}",
@ -657,7 +845,7 @@ sub vitoconnect_Set {
}
elsif ( $opt eq "HK3-Heizkurve-Niveau" ) {
my $slope = ReadingsVal( $name, "HK3-Heizkurve-Steigung", "" );
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.2.heating.curve/setCurve",
"{\"shift\":$args[0],\"slope\":$slope}",
@ -667,7 +855,7 @@ sub vitoconnect_Set {
}
elsif ( $opt eq "HK1-Heizkurve-Steigung" ) {
my $shift = ReadingsVal( $name, "HK1-Heizkurve-Niveau", "" );
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.0.heating.curve/setCurve",
"{\"shift\":$shift,\"slope\":$args[0]}",
@ -677,7 +865,7 @@ sub vitoconnect_Set {
}
elsif ( $opt eq "HK2-Heizkurve-Steigung" ) {
my $shift = ReadingsVal( $name, "HK2-Heizkurve-Niveau", "" );
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.1.heating.curve/setCurve",
"{\"shift\":$shift,\"slope\":$args[0]}",
@ -687,7 +875,7 @@ sub vitoconnect_Set {
}
elsif ( $opt eq "HK3-Heizkurve-Steigung" ) {
my $shift = ReadingsVal( $name, "HK3-Heizkurve-Niveau", "" );
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.2.heating.curve/setCurve",
"{\"shift\":$shift,\"slope\":$args[0]}",
@ -702,7 +890,7 @@ sub vitoconnect_Set {
$t += ONE_DAY;
$end = $t->strftime("%Y-%m-%d");
}
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.0.operating.programs.holiday/schedule",
"{\"start\":\"$args[0]\",\"end\":\"$end\"}",
@ -717,7 +905,7 @@ sub vitoconnect_Set {
$t += ONE_DAY;
$end = $t->strftime("%Y-%m-%d");
}
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.1.operating.programs.holiday/schedule",
"{\"start\":\"$args[0]\",\"end\":\"$end\"}",
@ -732,7 +920,7 @@ sub vitoconnect_Set {
$t += ONE_DAY;
$end = $t->strftime("%Y-%m-%d");
}
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.2.operating.programs.holiday/schedule",
"{\"start\":\"$args[0]\",\"end\":\"$end\"}",
@ -742,7 +930,7 @@ sub vitoconnect_Set {
}
elsif ( $opt eq "HK1-Urlaub_Ende" ) {
my $start = ReadingsVal( $name, "HK1-Urlaub_Start", "" );
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.0.operating.programs.holiday/schedule",
"{\"start\":\"$start\",\"end\":\"$args[0]\"}",
@ -752,7 +940,7 @@ sub vitoconnect_Set {
}
elsif ( $opt eq "HK2-Urlaub_Ende" ) {
my $start = ReadingsVal( $name, "HK2-Urlaub_Start", "" );
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.1.operating.programs.holiday/schedule",
"{\"start\":\"$start\",\"end\":\"$args[0]\"}",
@ -762,7 +950,7 @@ sub vitoconnect_Set {
}
elsif ( $opt eq "HK3-Urlaub_Ende" ) {
my $start = ReadingsVal( $name, "HK3-Urlaub_Start", "" );
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.2.operating.programs.holiday/schedule",
"{\"start\":\"$start\",\"end\":\"$args[0]\"}",
@ -771,79 +959,79 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "HK1-Urlaub_unschedule" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.0.operating.programs.holiday/unschedule",
"{}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK2-Urlaub_unschedule" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.1.operating.programs.holiday/unschedule",
"{}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK3-Urlaub_unschedule" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.2.operating.programs.holiday/unschedule",
"{}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK1-Zeitsteuerung_Heizung" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.0.heating.schedule/setSchedule",
"{\"newSchedule\":@args}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK2-Zeitsteuerung_Heizung" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.1.heating.schedule/setSchedule",
"{\"newSchedule\":@args}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK3-Zeitsteuerung_Heizung" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.2.heating.schedule/setSchedule",
"{\"newSchedule\":@args}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK1-Betriebsart" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.0.operating.modes.active/setMode",
"{\"mode\":\"$args[0]\"}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK2-Betriebsart" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.1.operating.modes.active/setMode",
"{\"mode\":\"$args[0]\"}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK3-Betriebsart" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.2.operating.modes.active/setMode",
"{\"mode\":\"$args[0]\"}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK1-Solltemperatur_comfort_aktiv" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.0.operating.programs.comfort/$args[0]",
"{}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK2-Solltemperatur_comfort_aktiv" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.1.operating.programs.comfort/$args[0]",
"{}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK3-Solltemperatur_comfort_aktiv" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.2.operating.programs.comfort/$args[0]",
"{}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK1-Solltemperatur_comfort" ) {
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.0.operating.programs.comfort/setTemperature",
"{\"targetTemperature\":$args[0]}",
@ -852,7 +1040,7 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "HK2-Solltemperatur_comfort" ) {
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.1.operating.programs.comfort/setTemperature",
"{\"targetTemperature\":$args[0]}",
@ -861,7 +1049,7 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "HK3-Solltemperatur_comfort" ) {
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.2.operating.programs.comfort/setTemperature",
"{\"targetTemperature\":$args[0]}",
@ -870,26 +1058,26 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "HK1-Solltemperatur_eco_aktiv" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.0.operating.programs.eco/$args[0]",
"{}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK2-Solltemperatur_eco_aktiv" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.1.operating.programs.eco/$args[0]",
"{}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK3-Solltemperatur_eco_aktiv" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.circuits.2.operating.programs.eco/$args[0]",
"{}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK1-Solltemperatur_normal" ) {
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.0.operating.programs.normal/setTemperature",
"{\"targetTemperature\":$args[0]}",
@ -898,7 +1086,7 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "HK2-Solltemperatur_normal" ) {
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.0.operating.programs.normal/setTemperature",
"{\"targetTemperature\":$args[0]}",
@ -907,7 +1095,7 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "HK3-Solltemperatur_normal" ) {
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.0.operating.programs.normal/setTemperature",
"{\"targetTemperature\":$args[0]}",
@ -916,7 +1104,7 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "HK1-Solltemperatur_reduziert" ) {
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.1.operating.programs.reduced/setTemperature",
"{\"targetTemperature\":$args[0]}",
@ -925,7 +1113,7 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "HK2-Solltemperatur_reduziert" ) {
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.2.operating.programs.reduced/setTemperature",
"{\"targetTemperature\":$args[0]}",
@ -934,7 +1122,7 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "HK3-Solltemperatur_reduziert" ) {
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.circuits.0.operating.programs.reduced/setTemperature",
"{\"targetTemperature\":$args[0]}",
@ -943,44 +1131,44 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "HK1-Name" ) {
vitoconnect_action2( $hash, "heating.circuits.0/setName",
vitoconnect_action( $hash, "heating.circuits.0/setName",
"{\"name\":\"@args\"}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK2-Name" ) {
vitoconnect_action2( $hash, "heating.circuits.1/setName",
vitoconnect_action( $hash, "heating.circuits.1/setName",
"{\"name\":\"@args\"}", $name, $opt, @args );
return;
}
elsif ( $opt eq "HK3-Name" ) {
vitoconnect_action2( $hash, "heating.circuits.2/setName",
vitoconnect_action( $hash, "heating.circuits.2/setName",
"{\"name\":\"@args\"}", $name, $opt, @args );
return;
}
elsif ( $opt eq "WW-einmaliges_Aufladen" ) {
vitoconnect_action2( $hash, "heating.dhw.oneTimeCharge/$args[0]",
vitoconnect_action( $hash, "heating.dhw.oneTimeCharge/$args[0]",
"{}", $name, $opt, @args );
return;
}
elsif ( $opt eq "WW-Zirkulationspumpe_Zeitplan" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.dhw.pumps.circulation.schedule/setSchedule",
"{\"newSchedule\":@args}", $name, $opt, @args );
return;
}
elsif ( $opt eq "WW-Zeitplan" ) {
vitoconnect_action2( $hash, "heating.dhw.schedule/setSchedule",
vitoconnect_action( $hash, "heating.dhw.schedule/setSchedule",
"{\"newSchedule\":@args}", $name, $opt, @args );
return;
}
elsif ( $opt eq "WW-Haupttemperatur" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.dhw.temperature.main/setTargetTemperature",
"{\"temperature\":$args[0]}", $name, $opt, @args );
return;
}
elsif ( $opt eq "WW-Solltemperatur" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.dhw.temperature/setTargetTemperature",
"{\"temperature\":$args[0]}", $name, $opt, @args );
return;
@ -993,7 +1181,7 @@ sub vitoconnect_Set {
$end = $t->strftime("%Y-%m-%d");
}
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.operating.programs.holiday/schedule",
"{\"start\":\"$args[0]\",\"end\":\"$end\"}",
@ -1003,7 +1191,7 @@ sub vitoconnect_Set {
}
elsif ( $opt eq "Urlaub_Ende" ) {
my $start = ReadingsVal( $name, "Urlaub_Start", "" );
vitoconnect_action2(
vitoconnect_action(
$hash,
"heating.operating.programs.holiday/schedule",
"{\"start\":\"$start\",\"end\":\"$args[0]\"}",
@ -1012,7 +1200,7 @@ sub vitoconnect_Set {
return;
}
elsif ( $opt eq "Urlaub_unschedule" ) {
vitoconnect_action2( $hash,
vitoconnect_action( $hash,
"heating.operating.programs.holiday/unschedule",
"{}", $name, $opt, @args );
return;
@ -1092,6 +1280,14 @@ sub vitoconnect_Attr {
return $err;
}
}
elsif ( $attr_name eq "vitoconnect_gw_readings" ) {
if ( $attr_value !~ /^0|1$/ ) {
my $err =
"Invalid argument $attr_value to $attr_name. Must be 0 or 1.";
Log 1, "$name - " . $err;
return $err;
}
}
elsif ( $attr_name eq "vitoconnect_actions_active" ) {
if ( $attr_value !~ /^0|1$/ ) {
my $err =
@ -1127,6 +1323,8 @@ sub vitoconnect_GetUpdate {
}
else {
vitoconnect_getResource($hash);
#vitoconnect_getCode($hash);
}
return;
}
@ -1134,10 +1332,8 @@ sub vitoconnect_GetUpdate {
sub vitoconnect_getCode {
my ($hash) = @_;
my $name = $hash->{NAME};
my $isiwebpasswd = vitoconnect_ReadKeyValue( $hash, "passwd" );
my $param = {
my $param = {
url => "$authorizeURL?client_id=$client_id"
. "&scope=openid&redirect_uri=$callback_uri"
. "&response_type=code",
@ -1291,11 +1487,44 @@ sub vitoconnect_getGwCallback {
$file_handle->print( Dumper($decode_json) );
}
# my $aggregatedStatus =
# $decode_json->{entities}[0]->{properties}->{aggregatedStatus};
# Log3 $name, 4, "$name - aggregatedStatus: $aggregatedStatus";
# readingsSingleUpdate( $hash, "aggregatedStatus",
# "$aggregatedStatus (" . TimeNow() . ")", 1 );
#Baustelle!!
if ( AttrVal( $name, "vitoconnect_gw_readings", 0 ) eq "1" ) {
readingsBeginUpdate($hash);
my $e = "0";
for my $entity ( @{ $decode_json->{entities} } ) {
my $FieldName = "entity" . $e;
readingsBulkUpdate(
$hash,
$FieldName . ".class",
$entity->{class}[0]
);
my %Properties = %{ $entity->{properties} };
my @Keys = keys(%Properties);
for my $Key (@Keys) {
readingsBulkUpdate( $hash, $FieldName . ".property." . $Key,
$Properties{$Key} );
}
my $e2 = "0";
for my $entity2 ( @{ $entity->{entities} } ) {
my $FieldName2 = $FieldName . ".entity" . $e2;
readingsBulkUpdate(
$hash,
$FieldName2 . ".class",
$entity2->{class}[0]
);
# my %Properties2 = %{ $entity2->{properties} };
# my @Keys2 = keys(%Properties);
# for my $Key2 (@Keys2) {
# readingsBulkUpdate( $hash, $FieldName2 .".property" . $Key2,
# $Properties2{$Key2} );
# }
$e2 = $e2 + 1;
}
$e = $e + 1;
}
readingsEndUpdate( $hash, 1 );
}
my $installation = $decode_json->{entities}[0]->{properties}->{id};
Log3 $name, 4, "$name - installation: $installation";
@ -1361,8 +1590,7 @@ sub vitoconnect_getResourceCallback {
return;
}
my $items = $decode_json;
if ( !$items->{errorType} eq "" ) {
if ( !$items->{statusCode} eq "" ) {
Log3 $name, 4,
"$name - statusCode: $items->{statusCode} "
. "errorType: $items->{errorType} "
@ -1377,9 +1605,46 @@ sub vitoconnect_getResourceCallback {
. "error: $items->{error}",
1
);
vitoconnect_getCode($hash);
return;
if ( $items->{statusCode} eq "401" ) {
# EXPIRED TOKEN
vitoconnect_getCode($hash);
return;
}
elsif ( $items->{statusCode} eq "404" ) {
# DEVICE_NOT_FOUND
Log3 $name, 1, "$name - Device not found: Optolink prüfen!";
InternalTimer( gettimeofday() + $hash->{intervall},
"vitoconnect_GetUpdate", $hash );
return;
}
elsif ( $items->{statusCode} eq "429" ) {
# RATE_LIMIT_EXCEEDED
Log3 $name, 1,
"$name - Anzahl der möglichen API Calls in überschritten!";
InternalTimer( gettimeofday() + $hash->{intervall},
"vitoconnect_GetUpdate", $hash );
return;
}
elsif ( $items->{statusCode} eq "502" ) {
# DEVICE_COMMUNICATION_ERROR error: Bad Gateway
Log3 $name, 1, "$name - temporärer API Fehler";
InternalTimer( gettimeofday() + $hash->{intervall},
"vitoconnect_GetUpdate", $hash );
return;
}
else {
Log3 $name, 1, "$name - unbekannter Fehler: "
. "Bitte den Entwickler informieren!";
InternalTimer( gettimeofday() + $hash->{intervall},
"vitoconnect_GetUpdate", $hash );
return;
}
}
readingsBeginUpdate($hash);
if ( $hash->{".logResponseOnce"} ) {
my $dir = path( AttrVal( "global", "logdir", "log" ) );
@ -1391,6 +1656,7 @@ sub vitoconnect_getResourceCallback {
my $file2 = $dir->child("actions.json");
$file_handle2 = $file2->openw_utf8();
}
for my $item ( @{ $items->{entities} } ) {
my $FieldName = $item->{class}[0];
Log3 $name, 5, "$name - FieldName $FieldName";
@ -1476,7 +1742,7 @@ sub vitoconnect_getResourceCallback {
"vitoconnect_GetUpdate", $hash );
return;
}
readingsBulkUpdate( $hash, "state", "ok" );
readingsBulkUpdate( $hash, "state", "last update: " . TimeNow() . "" );
readingsEndUpdate( $hash, 1 );
InternalTimer( gettimeofday() + $hash->{intervall},
"vitoconnect_GetUpdate", $hash );
@ -1485,102 +1751,11 @@ sub vitoconnect_getResourceCallback {
}
sub vitoconnect_action {
my ($hash) = @_;
my $name = $hash->{NAME};
my $isiwebuserid = $hash->{user};
my $isiwebpasswd = vitoconnect_ReadKeyValue( $hash, "passwd" );
my $err = "";
my $response_body = "";
my $code = "";
my $access_token = "";
my $installation = "";
my $gw = "";
my $param = {
url => "$authorizeURL?client_id=$client_id&scope=openid"
. "&redirect_uri=$callback_uri&response_type=code",
hash => $hash,
header => "Content-Type: application/x-www-form-urlencoded",
ignoreredirects => 1,
user => $isiwebuserid,
pwd => $isiwebpasswd,
sslargs => { SSL_verify_mode => 0 },
timeout => 10,
method => "POST"
};
#Log3 $name, 4, "$name - user=$param->{user} passwd=$param->{pwd}";
( $err, $response_body ) = HttpUtils_BlockingGet($param);
if ( $err eq "" ) {
$response_body =~ /code=(.*)"/;
$code = $1;
Log3 $name, 5, "$name - response_body: $response_body";
Log3 $name, 4, "$name - code: $code";
}
else { Log3 $name, 1, "$name - An error occured: $err"; }
$param = {
url => $token_url,
hash => $hash,
header =>
"Content-Type: application/x-www-form-urlencoded;charset=utf-8",
data => "client_id=$client_id&client_secret=$client_secret&code=$code"
. "&redirect_uri=$callback_uri&grant_type=authorization_code",
sslargs => { SSL_verify_mode => 0 },
timeout => 10,
method => "POST"
};
( $err, $response_body ) = HttpUtils_BlockingGet($param);
if ( $err eq "" ) {
my $decode_json = eval { decode_json($response_body) };
if ($@) {
Log3 $name, 1, "$name - JSON error while request: $@";
InternalTimer( gettimeofday() + $hash->{intervall},
"vitoconnect_GetUpdate", $hash );
return;
}
$access_token = $decode_json->{access_token};
Log3 $name, 5, "$name - access_token: $access_token";
}
else {
Log3 $name, 1, "$name - getAccessToken: An error occured: $err";
}
$param = {
url => "$apiURLBase$general",
hash => $hash,
header => "Authorization: Bearer $access_token",
timeout => 10,
sslargs => { SSL_verify_mode => 0 }
};
( $err, $response_body ) = HttpUtils_BlockingGet($param);
if ( $err eq "" ) {
Log3 $name, 5, "$name - action (installation and gw): $response_body";
my $decode_json = eval { decode_json($response_body) };
if ($@) {
Log3 $name, 1, "$name - JSON error while request: $@";
InternalTimer( gettimeofday() + $hash->{intervall},
"vitoconnect_GetUpdate", $hash );
return;
}
$installation = $decode_json->{entities}[0]->{properties}->{id};
$gw =
$decode_json->{entities}[0]->{entities}[0]->{properties}->{serial};
Log3 $name, 4, "$name - installation: $installation :: gw: $gw";
}
else { Log3 $name, 1, "$name - An error occured: $err"; }
return;
}
sub vitoconnect_action2 {
my ( $hash, $feature, $data, $name, $opt, @args ) = @_;
my $access_token = $hash->{".access_token"};
my $installation = $hash->{".installation"};
my $gw = $hash->{".gw"};
#vitoconnect_action($hash);
my $param = {
url => "$apiURLInst/$installation/gateways/$gw/"
. "devices/0/features/$feature",
@ -1595,6 +1770,7 @@ sub vitoconnect_action2 {
Log3 $name, 4, "$name - url=$param->{url}";
Log3 $name, 4, "$name - data=$param->{data}";
( my $err, my $msg ) = HttpUtils_BlockingGet($param);
if ( $err ne "" || $msg ne "" ) {
Log3 $name, 1, "$name - set $name $opt @args: Fehler während der"
. "Befehlsausführung: $err :: $msg";
@ -1817,7 +1993,7 @@ sub vitoconnect_ReadKeyValue {
<br><br>
Attributes:
<ul>
<li><i>disable</i>:<br>
<li><i>disable</i>:<br>
stop communication with Viessmann server
</li>
<li><i>verbose</i>:<br>
@ -1827,6 +2003,10 @@ sub vitoconnect_ReadKeyValue {
create readings with plain JSON names like 'heating.circuits.0.heating.curve.slope'
instead of german identifiers
</li>
<li><i>vitoconnect_gw_readings</i>:<br>
create readings from the gateway
</li>
<li><i>vitoconnect_actions_active</i>:<br>
create readings for actions e.g. 'heating.circuits.0.heating.curve.setCurve'
</li>