Nachdem ich den Eintrag von „shdefender“ zum Thema auslesen der archivierten Werte des NEDAP Powerrouters gesehen hatte wollte ich endlich die aktuellen Werte des Wechselrichters in IPS sichtbar machen. Anbei das Script welches dies für mich bewerkstelligt (bestimmt keine Schönheit aber es läuft.
Herangehensweise
Das Problem bei den NEDAP Wechselrichtern ist, dass sie zwar über eine sehr schönes Cloud Portal verfügen, man von hier aber nichts wirklich sinnvolles auf einfachem Wege auslesen kann - ebenso geht hier nichts lokal, obwohl der Router im Netz hängt. Dank dem o.g. Eintrags gibt es nun einen Weg via CURL auf die Werte zuzugreifen - da ich aber CURL nicht wirklich verstanden habe, zerlege ich die Were mit einer exploder Funktion und lösche die nicht benötigten Werte.
Konfiguration
- Username und Passwort eintragen von „https://mypowerrouter.com/“
- ID des Powerrouters eintragen (bekommt man aus der [mypowerrouter.com/power_routers/12345)
Das wars es … sollte man nicht alle Werte benötigen oder Variablen sparen wollen, einfach die Sektion mit /* */ ausklammern.
Alle genötigten Variablen werden automatisch angelegt.
<?
// Logindaten zu my.powerrouter.com hier eintragen
$username = "*****";
$password = "****";
$Powerrouter_ID = "****";
// Ab hier nichts mehr ändern, es sei denn es sollen Variablen entfernt werden.
// Seite auslesen und speichern
$curl = curl_init('https://mypowerrouter.com/power_routers/'.$Powerrouter_ID.'#tab-status');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$page = curl_exec($curl);
//echo $page,"
"; //An dieser Stelle kann man alle Werte ausgeben - zur Kontrolle
$wert = explode(",", $page); // Zerlegen des Strings
// Hier kann man Text einfügen der entfernt werden soll
$Zu_Loeschende_Werte = array("to_","gr","id","power_router","serialnumber","description","heartbeat","is_online","firmware_version","status","sensor","local_out","system","in_maintenance_charge","winter_mode","solar","power_string1","power_string2","direct_use","to_battery","to_grid","battery","power","state_of_charge","charge_status","{","(",":","\"",":","}");
//PowerRouter ID
$power_router_id = str_replace($Zu_Loeschende_Werte,"",$wert[0]);
$ID_power_router_id = @IPS_GetVariableIDByName("Powerrouter ID", $_IPS['SELF']);
if($ID_power_router_id === false)
{
$ID_power_router_id = IPS_CreateVariable(3);
IPS_SetName($ID_power_router_id, "Powerrouter ID");
IPS_SetParent($ID_power_router_id, $_IPS['SELF']);
}
SetValue($ID_power_router_id,$power_router_id);
//Seriennummer des Powerrouters
$serialnumber = str_replace($Zu_Loeschende_Werte,"",$wert[1]);
$ID_serialnumber = @IPS_GetVariableIDByName("Seriennummer", $_IPS['SELF']);
if($ID_serialnumber === false)
{
$ID_serialnumber = IPS_CreateVariable(3);
IPS_SetName($ID_serialnumber, "Seriennummer");
IPS_SetParent($ID_serialnumber, $_IPS['SELF']);
}
SetValue($ID_serialnumber,$serialnumber);
//Name Powerrouter
$name = str_replace($Zu_Loeschende_Werte,"",$wert[2]);
$ID_name = @IPS_GetVariableIDByName("Powerrouter Name", $_IPS['SELF']);
if($ID_name === false)
{
$ID_name = IPS_CreateVariable(3);
IPS_SetName($ID_name, "Powerrouter Name");
IPS_SetParent($ID_name, $_IPS['SELF']);
}
SetValue($ID_name,$name);
//Heartbeat Powerrouter
$heartbeat = str_replace($Zu_Loeschende_Werte,"",$wert[3]);
$ID_heartbeat = @IPS_GetVariableIDByName("Heartbeat", $_IPS['SELF']);
if($ID_heartbeat === false)
{
$ID_heartbeat = IPS_CreateVariable(3);
IPS_SetName($ID_heartbeat, "Heartbeat");
IPS_SetParent($ID_heartbeat, $_IPS['SELF']);
}
SetValue($ID_heartbeat,$heartbeat);
//Online
$online = str_replace($Zu_Loeschende_Werte,"",$wert[4]);
$ID_online = @IPS_GetVariableIDByName("Powerrouter Online", $_IPS['SELF']);
if($ID_online === false)
{
$ID_online = IPS_CreateVariable(0);
IPS_SetName($ID_online, "Powerrouter Online");
IPS_SetParent($ID_online, $_IPS['SELF']);
}
SetValue($ID_online,$online);
//Firmware Version
$firmware = str_replace($Zu_Loeschende_Werte,"",$wert[5]);
$ID_firmware = @IPS_GetVariableIDByName("Powerrouter Firmware Version", $_IPS['SELF']);
if($ID_firmware === false)
{
$ID_firmware = IPS_CreateVariable(3);
IPS_SetName($ID_firmware, "Powerrouter Firmware Version");
IPS_SetParent($ID_firmware, $_IPS['SELF']);
}
SetValue($ID_firmware,$firmware);
//Status Grid
$status_grid = str_replace($Zu_Loeschende_Werte,"",$wert[6]);
$ID_status_grid = @IPS_GetVariableIDByName("Status Netz", $_IPS['SELF']);
if($ID_status_grid === false)
{
$ID_status_grid = IPS_CreateVariable(2);
IPS_SetName($ID_status_grid, "Status Netz");
IPS_SetParent($ID_status_grid, $_IPS['SELF']);
}
SetValue($ID_status_grid,$status_grid);
//Status 3-phasen Sensor
$status_sensor = str_replace($Zu_Loeschende_Werte,"",$wert[7]);
$ID_status_sensor = @IPS_GetVariableIDByName("3-phasen Sensor", $_IPS['SELF']);
if($ID_status_sensor === false)
{
$ID_status_sensor = IPS_CreateVariable(2);
IPS_SetName($ID_status_sensor, "3-phasen Sensor");
IPS_SetParent($ID_status_sensor, $_IPS['SELF']);
}
SetValue($ID_status_sensor,$status_sensor);
//Local Out
$local_out = str_replace($Zu_Loeschende_Werte,"",$wert[8]);
$ID_local_out = @IPS_GetVariableIDByName("Local Out", $_IPS['SELF']);
if($ID_local_out === false)
{
$ID_local_out = IPS_CreateVariable(2);
IPS_SetName($ID_local_out, "Local Out");
IPS_SetParent($ID_local_out, $_IPS['SELF']);
}
SetValue($ID_status_sensor,$status_sensor);
//System
$system = str_replace($Zu_Loeschende_Werte,"",$wert[9]);
$ID_system = @IPS_GetVariableIDByName("System", $_IPS['SELF']);
if($ID_system === false)
{
$ID_system = IPS_CreateVariable(2);
IPS_SetName($ID_system, "System");
IPS_SetParent($ID_system, $_IPS['SELF']);
}
SetValue($ID_system,$system);
//Wartungsladung
$maintenance_charge = str_replace($Zu_Loeschende_Werte,"",$wert[10]);
$ID_maintenance_charge = @IPS_GetVariableIDByName("Wartungsladen", $_IPS['SELF']);
if($ID_maintenance_charge === false)
{
$ID_maintenance_charge = IPS_CreateVariable(0);
IPS_SetName($ID_maintenance_charge, "Wartungsladen");
IPS_SetParent($ID_maintenance_charge, $_IPS['SELF']);
}
SetValue($ID_maintenance_charge,$maintenance_charge);
//Wintermodus
$winter = str_replace($Zu_Loeschende_Werte,"",$wert[11]);
$ID_winter = @IPS_GetVariableIDByName("Wintermodus", $_IPS['SELF']);
if($ID_winter === false)
{
$ID_winter = IPS_CreateVariable(0);
IPS_SetName($ID_winter, "Wintermodus");
IPS_SetParent($ID_winter, $_IPS['SELF']);
}
SetValue($ID_winter,$winter);
//Solar
$solar = str_replace($Zu_Loeschende_Werte,"",$wert[12]);
$ID_solar = @IPS_GetVariableIDByName("Solar", $_IPS['SELF']);
if($ID_solar === false)
{
$ID_solar = IPS_CreateVariable(2);
IPS_SetName($ID_solar, "Solar");
IPS_SetParent($ID_solar, $_IPS['SELF']);
}
SetValue($ID_solar,$solar);
//String1
$string1 = str_replace($Zu_Loeschende_Werte,"",$wert[13]);
$ID_string1 = @IPS_GetVariableIDByName("String 1", $_IPS['SELF']);
if($ID_string1 === false)
{
$ID_string1 = IPS_CreateVariable(2);
IPS_SetName($ID_string1, "String 1");
IPS_SetParent($ID_string1, $_IPS['SELF']);
}
SetValue($ID_string1,$string1);
//String2
$string2 = str_replace($Zu_Loeschende_Werte,"",$wert[14]);
$ID_string2 = @IPS_GetVariableIDByName("String 2", $_IPS['SELF']);
if($ID_string2 === false)
{
$ID_string2 = IPS_CreateVariable(2);
IPS_SetName($ID_string2, "String 2");
IPS_SetParent($ID_string2, $_IPS['SELF']);
}
SetValue($ID_string2,$string2);
//Eigenverbrauch
$direct_use = str_replace($Zu_Loeschende_Werte,"",$wert[15]);
$ID_direct_use = @IPS_GetVariableIDByName("Eigenverbrauch", $_IPS['SELF']);
if($ID_direct_use === false)
{
$ID_direct_use = IPS_CreateVariable(2);
IPS_SetName($ID_direct_use, "Eigenverbrauch");
IPS_SetParent($ID_direct_use, $_IPS['SELF']);
}
SetValue($ID_direct_use,$direct_use);
//An Batterie
$to_battery = str_replace($Zu_Loeschende_Werte,"",$wert[16]);
$ID_to_battery = @IPS_GetVariableIDByName("An Batterie", $_IPS['SELF']);
if($ID_to_battery === false)
{
$ID_to_battery = IPS_CreateVariable(2);
IPS_SetName($ID_to_battery, "An Batterie");
IPS_SetParent($ID_to_battery, $_IPS['SELF']);
}
SetValue($ID_to_battery,$to_battery);
//Einspeisung ins Netz
$to_grid = str_replace($Zu_Loeschende_Werte,"",$wert[17]);
$ID_to_grid = @IPS_GetVariableIDByName("Einspeisung in Netz", $_IPS['SELF']);
if($ID_to_grid === false)
{
$ID_to_grid = IPS_CreateVariable(2);
IPS_SetName($ID_to_grid, "Einspeisung in Netz");
IPS_SetParent($ID_to_grid, $_IPS['SELF']);
}
SetValue($ID_to_grid,$to_grid);
//Batterie
$battery = str_replace($Zu_Loeschende_Werte,"",$wert[18]);
$ID_battery = @IPS_GetVariableIDByName("Batterie", $_IPS['SELF']);
if($ID_battery === false)
{
$ID_battery = IPS_CreateVariable(2);
IPS_SetName($ID_battery, "Batterie");
IPS_SetParent($ID_battery, $_IPS['SELF']);
}
SetValue($ID_battery,$battery);
//Batterie Ladung
$battery_charge = str_replace($Zu_Loeschende_Werte,"",$wert[19]);
$ID_battery_charge = @IPS_GetVariableIDByName("Batterie Ladung", $_IPS['SELF']);
if($ID_battery_charge === false)
{
$ID_battery_charge = IPS_CreateVariable(2);
IPS_SetName($ID_battery_charge, "Batterie Ladung");
IPS_SetParent($ID_battery_charge, $_IPS['SELF']);
}
SetValue($ID_battery_charge,$battery_charge);
//Charge Status setzen
$charge_status = str_replace($Zu_Loeschende_Werte,"",$wert[20]);
$ID_charge_status = @IPS_GetVariableIDByName("Batterie-Status", $_IPS['SELF']);
if($ID_charge_status === false)
{
$ID_charge_status = IPS_CreateVariable(3);
IPS_SetName($ID_charge_status, "Batterie-Status");
IPS_SetParent($ID_charge_status, $_IPS['SELF']);
}
SetValue($ID_charge_status,$charge_status);
?>