Viessmann VitoConnect API

Begonnen von ritschi, 22 März 2018, 06:53:24

Vorheriges Thema - Nächstes Thema

Frini

Ich habe gerade mal Deine php getestet. Funktioniert soweit.
Allerdings klappt die telnet Verbindung nicht.
PHP Notice:  fputs(): send of 51 bytes failed with errno=32 Broken pipe in /opt/fhem/viessmannhg.php on line 183

heiko73

Tja, schwierig.

Kann ich hier so spontan nicht nachvollziehen, habe getestet mit falschem Hostnamen für den FHEM Server und falschem Port (connection refused), aber "Broken Pipe" habe ich noch nicht gesehen. Läuft das PHP Script auf Deinem FHEM Server und ist das ein Raspi mit Linux oder irgendwas anderes?

Ach ja: der Telnet Port muss im Moment noch ohne Passwortschutz sein, hast Du das auch so?

Noch ne Idee: Bei der Verbindungsanbahnung gibt es einen sleep(4), eventuell mal mit dem Wert spielen und kleiner oder größer machen.


Frini

Hat geklappt.
Ich habe den telnetport noch mal gelöscht und dann bei der Definition das global weggelassen.
So ganz versteh ich das nicht.

heiko73

OK, konnte den Fehler nachstellen indem ich während des Ausführens des PHP Scripts (und nach dem Start der Telnet Verbindung) einen "shutdown restart" ausgeführt habe. "Broken Pipe" heisst soviel wie "Die Verbindung wurde erfolgreich aufgebaut, ist dann aber mittendrin weggebrochen".

Eventuell kannst Du auch für dieses Script einen eigenen Telnet Port definieren (mit anderer Portnummer), wenn Du den 7072 noch für andere Sachen brauchst.



thetrueavatar

Zitat von: onkeloki am 10 Oktober 2018, 09:20:49
Falls es jemanden etwas bringt hier ist mein php Schnippsel
ich habe es der einfachkeit halber in folgenden odner gelegt:

/home/pi/Viessmann-Api-master/example/SetInFhem.php
weil ich eh ein Example modifiziert habe bis es für mich geklappt hat..
Hier der code:

<?php
include __DIR__.'/bootstrap.php';
use 
Viessmann\API\ViessmannAPI;

function 
setTofhem($name,$val){
if(
$val == false){
$val "0"
}
$r =  "setreading ViessmannAPI ".$name." ".$val;
$addlog "trigger ViessmannAPI  ".$name.": ".$val."   << addLog";
echo 
$name.":".$val ."\n";
shell_exec('perl /opt/fhem/fhem.pl 7072 "'.$r.'"'); 
shell_exec('perl /opt/fhem/fhem.pl 7072 "'.$addlog.'"'); 
}

$getter = array();
$getter[] = "getOutsideTemperature";
$getter[] = "getBoilerTemperature";
$getter[] = "getSlope";
$getter[] = "getShift";
$getter[] = "getActiveMode";
$getter[] = "isHeatingBurnerActive";
$getter[] = "getNormalProgramTemperature";
$getter[] = "getReducedProgramTemperature";
$getter[] = "isInStandbyMode";

//$getter[] = "getActiveProgram";
//$getter[] = "getComfortProgramTemperature";
//$getter[] = "getEcoProgramTemperature";
//$getter[] = "getExternalProgramTemperature";
//$getter[] = "getSupplyProgramTemperature";
//$getter[] = "isDhwModeActive";

while (list($key$val) = each($getter))
  {
@
setTofhem($val$viessmannApi->$val());
  }






die "getter" welche bei mir seit gestern nicht mehr funktionieren (oauth error) sind auskommentier
ich vermute die gehen nicht mehr weil ich z.b. kein warm wasser habe und auch keinen eco mode


@thetrueavatar:
watch the commented rows.. this are the functions which stoped working for me
i think this is because my heater does not support this programs so maybe the vicare endpoint has changed .. yesterdey before 16:00 i got answers from this calls
now php runs into a oauth error ..
after oauth error the whole scrip breaks ;) so maybe its a good idea to catch the error or prevent the warning




die file rufe ich via "php -f /home/pi/Viessmann-Api-master/example/SetInFhem.php" auf   

das quellpaket ist hier zu finden
https://github.com/thetrueavatar/Viessmann-Api
I'm not sure it's totally related but I have just fixed a bug prevent the right use of default circuitId when upon ViessmanAPI instanciation. So default value for circuitId was always 0. Could you pull the new version of the phar and see if this fix de problem ?
If not could you send me the full error stack trace please ?
I have still some work to do on error management. Usually it's the client's responsability to catch the error and provide the right error management. However, I should at least catch oauth error and provide my own exception with some more explicit message about the error. I might add an "errorcode" to ease the error management too but I'm not yet there tbh.

thetrueavatar

For information, I have noticed that since yesterday viessmann service return me 3 more features than before including hotWaterStorageTemperature. I have been able to test it and have included a getHotWaterStorageTemperature method on the API. BTW, if you whish to add some method feel free to contribute. I have recently added too roomTemperature thanks to a contribution(I don't have room sensor).

thetrueavatar

Version 0.3 available on : https://github.com/thetrueavatar/Viessmann-Api/releases/tag/0.3
Add exception management to display more readable error
Added some new method:
getHotWaterStorageTemperature
getRoomTemperature and getSupplyTemperature thanks to the contribution of Xiaverg16
Added SetActiveMode.php
added the possibility to define deviceId and circuitId either on api instanciation(subsequent method call will use
-added json sample found into the Vicare Ap
- switch to curl client instead of streaming client

onkeloki

Zitat von: thetrueavatar am 12 Oktober 2018, 16:37:10
Version 0.3 available on : https://github.com/thetrueavatar/Viessmann-Api/releases/tag/0.3
Add exception management to display more readable error
Added some new method:
getHotWaterStorageTemperature
getRoomTemperature and getSupplyTemperature thanks to the contribution of Xiaverg16
Added SetActiveMode.php
added the possibility to define deviceId and circuitId either on api instanciation(subsequent method call will use
-added json sample found into the Vicare Ap
- switch to curl client instead of streaming client

thank you i give it a try

onkeloki

Zitat von: thetrueavatar am 12 Oktober 2018, 16:37:10
Version 0.3 available on : https://github.com/thetrueavatar/Viessmann-Api/releases/tag/0.3
Add exception management to display more readable error
Added some new method:
getHotWaterStorageTemperature
getRoomTemperature and getSupplyTemperature thanks to the contribution of Xiaverg16
Added SetActiveMode.php
added the possibility to define deviceId and circuitId either on api instanciation(subsequent method call will use
-added json sample found into the Vicare Ap
- switch to curl client instead of streaming client




Température extérieure 6.7
Température boiler 47
Pente 1.4
Parallèle 0
Mode chaudière dhwAndHeating
Programme actif eco
Is Heating Burner active ?
PHP Fatal error:  Uncaught TomPHP\Siren\Exception\NotFound: Property "active" was not found. in phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/exception-constructor-tools/src/ExceptionConstructorTools.php:27
Stack trace:
#0 phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/siren/src/Exception/NotFound.php(32): TomPHP\Siren\Exception\NotFound::create('Property "%s" w...', Array, 1)
#1 phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/siren/src/Entity.php(144): TomPHP\Siren\Exception\NotFound::forProperty('active')
#2 phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/src/API/ViessmannAPI.php(131): TomPHP\Siren\Entity->getProperty('active')
#3 /home/pi/Viessmann-Api-0.3/example/Main.php(14): Viessmann\API\ViessmannAPI->isDhwModeActive()
#4 {main}
  thrown in phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/exception-constructor-tools/src/ExceptionConstructorTools.php on line 27


there it is

i did ... php -f Main.php

thetrueavatar

#114
Well it seems that  you have got the feature(otherwise you would receive a FEATURE_NOT_FOUND message) but that you don't have any value for it. 
Does your viessmann manage hot water ?
If yes to find the problem could you add this line and provide me the result(don't worry there is no private data in the response) :
echo $viessmannApi->getRawJsonData("heating.circuits.0.operating.modes.dhw");

By default, viessmanApi use 0 as circuit. However, maybe is your dhw on circuit 1. Could you try with this call too:
echo "Is Dhw mode active ? " . $viessmannApi->isDhwModeActive(1) . "\n";
This would try to find data on circuit 1.

Frini

Viessmann updated their Vicare App to Version 2.1. Now it is possible to activate manuel heating of water storage.
I have the Vitodens 333 and here hotwaterstorage dhw is working without problems. The 333 has an integrated waten storage.

onkeloki

Zitat von: thetrueavatar am 20 Oktober 2018, 21:01:10
Well it seems that  you have got the feature(otherwise you would receive a FEATURE_NOT_FOUND message) but that you don't have any value for it. 
Does your viessmann manage hot water ?
If yes to find the problem could you add this line and provide me the result(don't worry there is no private data in the response) :
echo $viessmannApi->getRawJsonData("heating.circuits.0.operating.modes.dhw");

By default, viessmanApi use 0 as circuit. However, maybe is your dhw on circuit 1. Could you try with this call too:
echo "Is Dhw mode active ? " . $viessmannApi->isDhwModeActive(1) . "\n";
This would try to find data on circuit 1.



php -f SetInFhem.php
----PHP Fatal error:  Uncaught TomPHP\Siren\Exception\NotFound: Property "active" was not found. in phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/exception-constructor-tools/src/ExceptionConstructorTools.php:27
Stack trace:
#0 phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/siren/src/Exception/NotFound.php(32): TomPHP\Siren\Exception\NotFound::create('Property "%s" w...', Array, 1)
#1 phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/siren/src/Entity.php(144): TomPHP\Siren\Exception\NotFound::forProperty('active')
#2 phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/src/API/ViessmannAPI.php(131): TomPHP\Siren\Entity->getProperty('active')
#3 /home/pi/Viessmann-Api-0.3/example/SetInFhem.php(16): Viessmann\API\ViessmannAPI->isDhwModeActive(1)
#4 {main}
  thrown in phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/exception-constructor-tools/src/ExceptionConstructorTools.php on line 27


maybe this is because i have not warmwater tank?
i just use the viessmann for heating not for water

thetrueavatar

Zitat von: onkeloki am 20 Oktober 2018, 21:22:45


php -f SetInFhem.php
----PHP Fatal error:  Uncaught TomPHP\Siren\Exception\NotFound: Property "active" was not found. in phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/exception-constructor-tools/src/ExceptionConstructorTools.php:27
Stack trace:
#0 phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/siren/src/Exception/NotFound.php(32): TomPHP\Siren\Exception\NotFound::create('Property "%s" w...', Array, 1)
#1 phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/siren/src/Entity.php(144): TomPHP\Siren\Exception\NotFound::forProperty('active')
#2 phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/src/API/ViessmannAPI.php(131): TomPHP\Siren\Entity->getProperty('active')
#3 /home/pi/Viessmann-Api-0.3/example/SetInFhem.php(16): Viessmann\API\ViessmannAPI->isDhwModeActive(1)
#4 {main}
  thrown in phar:///home/pi/Viessmann-Api-0.3/example/Viessmann-Api-0.3.phar/vendor/tomphp/exception-constructor-tools/src/ExceptionConstructorTools.php on line 27


maybe this is because i have not warmwater tank?
i just use the viessmann for heating not for water
You're right. However, imho the viessmann service should return a NOT_FEATURE_FOUND instead of an json with no data... I will try to update error handling however to manage error coming from empty data.

Frini

Hi I have done a GetFeature few minutes ago. There are more adresses to use.


"class":["heating.gas.consumption.dhw","feature"],
"properties":{
"day":{"type":"array","value":[128,80,0,8,0,0,0]},
"week":{"type":"array","value":[88,288,640,904,64,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},
"month":{"type":"array","value":[1016,968,32,0,0,0,0,0,0,0,0,0]},"year":{"type":"array","value":[2016,0]}},

"class":["heating.gas.consumption.heating","feature"],
"properties":{
"day":{"type":"array","value":[128,80,0,8,0,0,0]},
"week":{"type":"array","value":[88,288,640,904,64,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},
"month":{"type":"array","value":[1016,968,32,0,0,0,0,0,0,0,0,0]},
"year":{"type":"array","value":[2016,0]}},


/devices/0/features/heating.dhw.oneTimeCharge"

"class":["heating.burner.current.power","feature"],
"properties":{
"value":{"type":"number","value":0}},




Es wurde definitiv etwas von Viessmann geändert.
Den rest habe ich angehangen.


thetrueavatar

I have already implemented most of those feature in the branch Feature/MethoNotYetTested . As I don't have the information on my heating I'm waiting some real test before including it into a release. Feel free to test it and provide me some feedback.