Do you run the script directly from Hassio?
Is there a way to do it?
It cannot be run directly from Hassio because it’s PHP, not Python. I wish I knew how to port it to Python.
I am not sure, but it seems that here is described a way how to do it.
To read the whole package of available data in json format is following part of the script:
function Vistapool_ReadData()
{
Global $poolID;
Global $password;
Global $username;
Global $ServerOS;
Global $WebsiteURL;
// Try to log in to the website with Cookie
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if (strtolower($ServerOS) == "windows")
{
curl_setopt($ch, CURLOPT_COOKIEFILE, 'C:\Windows\Temp\vistapool_cookie');
}
else
{
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/vistapool_cookie');
}
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $WebsiteURL.'/de/pool/list');
$curlData = curl_exec($ch);
// Check if the login with cookie was successful, if not, then a normal login will be done
preg_match("|(Passwort wiederherstellen)|", $curlData, $LoginFALSE);
if ($LoginFALSE)
{
echo "Anmeldung mit Cookie war nicht erfolgreich - normaler Login wird durchgeführt!".PHP_EOL;
$fields = array(
'user'=>urlencode($username),
'pass'=>urlencode($password),
'remember_password'=>'0',
'entrar'=>'Eingabe',
);
$fields_string = '';
foreach($fields as $key=>$value) {
$fields_string .= $key.'='.$value.'&';
}
$fields_string = substr($fields_string,0,-1);
$postfields = $fields_string;
ini_set("max_execution_time", 60);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if (strtolower($ServerOS) == "windows")
{
curl_setopt($ch, CURLOPT_COOKIEFILE, 'C:\Windows\Temp\vistapool_cookie');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'C:\Windows\Temp\vistapool_cookie');
}
else
{
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/vistapool_cookie');
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/vistapool_cookie');
}
curl_setopt($ch, CURLOPT_COOKIE, session_name().'='.session_id());
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_URL, $WebsiteURL.'/de/login/login');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$postfields");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlData = curl_exec($ch);
}
// Querying the pool data
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $WebsiteURL.'/de/pool/getmainvalues?id='.$poolID.'&hasPH=true&hasRX=true&hasCL=true&hasCD=true&config=1&hasHidro=true&hasLight=true&hasRelays=true&numRelays=1%2C2%2C3%2C4&hasFiltration=true&hasBackwash=true&hasIO=true&hasUV=true&needsTimeBesgoRemaining=false');
$curlData = curl_exec($ch);
// Output of read data
if ($curlData == '"not connected"')
{
// Pool control is offline - data can not be read
echo "POOLSTEUERUNG IST NICHT VERBUNDEN!".PHP_EOL;
IPS_LogMessage("VISTAPOOL", "POOLSTEUERUNG IST NICHT VERBUNDEN!");
}
else
{
// Pool control is online - data can be read
$PoolData_Array = json_decode($curlData, true);
return $PoolData_Array;
}
// cURL session ending
curl_close($ch);
Technically it is going through login and open following page:
http://vistapool.es/en/pool/getmainvalues?id=poolID
where the content of the web above is:
{“temp”:“29.7\u00baC”,“local_time”:“17:49”,“lightStat”:{“status”:{“type”:“MAN”,“status”:“OFF”}},“filtration_stat”:“OFF”,“filtration_mode”:“HEATING”,“filtration_time_remaining”:0,“PH”:“7.0”,“PH_status”:{“alarm”:"",“type”:“ACID”,“hi_value”:“7.3”,“status”:0,“color”:{“class”:“grey”,“hex”:"#dddddd"}},“RX”:0,“RX1”:700,“RXColor”:{“class”:“grey”,“hex”:"#dddddd"},“RX_status”:{“status”:"",“current”:"",“hidro”:""},“CL”:“0.00”,“CL1”:“1.00”,“CLColor”:{“class”:“grey”,“hex”:"#dddddd"},“CL_status”:{“hidro”:“FL2”,“status”:"",“current”:""},“CD”:0,“CD1”:5000,“CDColor”:{“class”:“grey”,“hex”:"#dddddd"},“CD_status”:“OFF”}
If anybody is able to perform it directly from HASSIO - it would be done
Hello everybody, would you please help me how to get this value
from here
using scrape sensor@hassio? thank you!
long time ago but let’s have this answered. because i just started making sensor of my own based on a web and mine doesn’t work that simple…
- platform: scrape
resource: Vízügyi honlap
select: “td”
index: 2