Forfatter Emne: http get / post  (Læst 707 gange)

0 Medlemmer og 1 Gæst læser dette emne.

Offline lassewt

  • Begynder
  • *
  • Indlæg: 8
  • Respekt optjent: +0/-0
http get / post
« Dato: Aug 06, 2017, 15:50 »
Hej

Findes der "simple " http post kommandoer til at ændre på fyrets settings, så man kan sende en "kommando " via web og ændre fyret istedet for at skulle ind manuelt og ændre det ?

Offline motoz

  • Top of the pop
  • *****
  • Indlæg: 214
  • Respekt optjent: +15/-0
Sv: http get / post
« Svar #1 Dato: Aug 07, 2017, 09:35 »
The controller does not contain an http server. You can use stokercloud, or if you want a local solution then you could use pellmon eg. on a raspberry or any old pc with linux, or in a virtual machine running linux on your windows pc.

Pellmon contains a webserver where you can GET settings with eg:
Kode: [Vælg]
GET /pellmon/getparam/boiler-tempwhich return the JSON data:
Kode: [Vælg]
value "65"
param "boiler-temp"

and change settings with POST, eg:
Kode: [Vælg]
POST /pellmon/setparam/alarm-max_shaft_temp
with params:
data: "50"

setparam/ requires a logged in user, so you need to POST username and password to /pellmon/auth/login and keep track of the session_id cookie.

Another option would be to set up a webserver pretending to be stokercloud, and a dns server to fool the burner to talk to your 'stokercloud' instead of the real one. But that's a lot of trouble and won't ever be nearly as good as just using the existing nice and fast UDP protocol.
Bio Comfort 30kW, compressor cleaning, lambda. Termax 25cr boiler. Matene vertical pellet conveyor. PellMon open source pellet logger: https://github.com/motoz/PellMon

Offline lassewt

  • Begynder
  • *
  • Indlæg: 8
  • Respekt optjent: +0/-0
Sv: http get / post
« Svar #2 Dato: Aug 07, 2017, 12:44 »
thanks for the reply

is there a simpel way to change settings on the burner from stokercloud.
im already getting status from stocker cloud via json outputtet..
Hope there is af oneline simpel command to stocker cloud. :)

Offline motoz

  • Top of the pop
  • *****
  • Indlæg: 214
  • Respekt optjent: +15/-0
Sv: http get / post
« Svar #3 Dato: Aug 07, 2017, 13:06 »
You can use the developer tools in your browser (ctrl-shift-k in firefox) and look at the network tab when changing a setting in stokercloud to see what it does.
Bio Comfort 30kW, compressor cleaning, lambda. Termax 25cr boiler. Matene vertical pellet conveyor. PellMon open source pellet logger: https://github.com/motoz/PellMon

Offline motoz

  • Top of the pop
  • *****
  • Indlæg: 214
  • Respekt optjent: +15/-0
Sv: http get / post
« Svar #4 Dato: Aug 14, 2017, 17:54 »
Did you give up? Anyway, here are some pointers to get you a bit further:

Using CURL to login to stokercloud:
Kode: [Vælg]
curl 'http://www.stokercloud.dk/dev/yourusername.html' -H 'Host: www.stokercloud.dk' --cookie-jar ./somefile --data 'username=yourusername&password=urlencodedpassword&action=login&tpg='
And then change hopper contents to 500 kg:
Kode: [Vælg]
curl 'http://www.stokercloud.dk/dev/updateajax.php?mac=yourusername&panel=2' --cookie ./somefile -H 'Host: www.stokercloud.dk' -H 'Content-Type: application/x-www-form-urlencoded' -H 'X-Requested-With: XMLHttpRequest' --data 'data=%7b%22field9%22%3a%22300%22%7d'
And to logout:
Kode: [Vælg]
curl 'http://www.stokercloud.dk/dev/yourusername.html' --cookie ./somefile -H 'Host: www.stokercloud.dk' --data 'logout=logout'
The password and form field data is urlencoded.
Bio Comfort 30kW, compressor cleaning, lambda. Termax 25cr boiler. Matene vertical pellet conveyor. PellMon open source pellet logger: https://github.com/motoz/PellMon

Offline lassewt

  • Begynder
  • *
  • Indlæg: 8
  • Respekt optjent: +0/-0
Sv: http get / post
« Svar #5 Dato: Aug 24, 2017, 00:48 »
Hej

nej ikke givet op, men var lidt mere op af bakke end hvad jeg havde håbet på. Tak for det nye forslag

jeg har fået den til måske at logge ind men linie 2 hvor den skal ændre en status på fyre siger den bad password

Offline motoz

  • Top of the pop
  • *****
  • Indlæg: 214
  • Respekt optjent: +15/-0
Sv: http get / post
« Svar #6 Dato: Aug 24, 2017, 06:20 »
Assuming you are on windows you probably have to change
Kode: [Vælg]
--cookie-jar ./somefile and
Kode: [Vælg]
--cookie ./somefileinto something like
Kode: [Vælg]
--cookie-jar .\somefileor just
Kode: [Vælg]
--cookie-jar somefile
Check that it creates the 'somefile' file in you current working directory.
Bio Comfort 30kW, compressor cleaning, lambda. Termax 25cr boiler. Matene vertical pellet conveyor. PellMon open source pellet logger: https://github.com/motoz/PellMon

Offline lassewt

  • Begynder
  • *
  • Indlæg: 8
  • Respekt optjent: +0/-0
Sv: http get / post
« Svar #7 Dato: Aug 24, 2017, 07:10 »
It makes the file..

Offline motoz

  • Top of the pop
  • *****
  • Indlæg: 214
  • Respekt optjent: +15/-0
Sv: http get / post
« Svar #8 Dato: Aug 24, 2017, 07:38 »
Hard to say then why it doesn't work for you.

I have made a stokercloud account to check it out  but as I don't actually use it I don't have my password here so I can't double check now that it works. What I did was just open the developer tools network tab in firefox, log on to stokercloud, locate the POST in the scrolling list of network traffic, right-click on it and choose 'copy as CURL'. Same when changing a setting. Then I added the --cookie-jar option to the login POST, and the --cookie option the the setting change so save and use the session cookie, removed some unnecessary looking stuff from the POST's and tried it out. It worked for me...

Bio Comfort 30kW, compressor cleaning, lambda. Termax 25cr boiler. Matene vertical pellet conveyor. PellMon open source pellet logger: https://github.com/motoz/PellMon