proditaki / OTGW-Domoticz-MQTT-Client

MQTT Client for OTGW project https://github.com/rvdbreemen/OTGW-firmware
3 stars 1 forks source link

Outside Temperature #1

Open PvdGulik opened 3 years ago

PvdGulik commented 3 years ago

Hello,

Would be nice if your client can set Outside temperature over MQTT by choosing a temperature device from Domoticz. And a field to send other commands.

Just like in the build-in OpenTherm Gateway with LAN-interface in Domoticz.

Thanks!

proditaki commented 3 years ago

I was looking into that. Have to find a good way to add this. Because you cannot add a setup page in the hardware page from a python plugin afaik. So would probably be a custom page.

arjanwaard commented 2 years ago

I use the following script that is run from crontab every 15 minutes :

#!/bin/bash

#fetch outside temp (use jq to parse JSON object correctly)
TEMP=`curl -s "http://127.0.0.1:8282/json.htm?type=devices&rid=312"  | jq '.result[0].Temp'`

#post using curl to API
curl -s -H "Content-Type:application/json" -d "OK"  http://10.0.1.196/api/v1/otgw/command/OT=$TEMP

Getting the outside temperature from domoticz on the local host/port, make sure to replace 312 with your device ID, and posting it to OTGW. Use the correct IP address in your situation.

Xenomes commented 2 years ago

Thanks for the script, was looking for something to add the outside temp.

ocmeros commented 2 years ago

Hello,

I also try to send the outdoor temperature to the OTGW, but I can't get it to work.

I'm using an odroid N2 with ubuntu and domoticz. Domoticz receives the OTGW value's with MQTT. The only thing I can't get working is sending the OT to the OTGW.

I've edited the bash script with the correct ip-addresses and port. I saved the script in a OT_script.sh file and made it executable with chmod +x OT_script.sh After that I got an jq not recognized error, but I solved that by installing jq. When I run the script now (./OT_script.sh) I get an OK as response, but I don't see the outdoor temperature value on the OTGW webinterface or my thermostat. Can you maybe give me a hint on how to get this working?

Remco

arjanwaard commented 2 years ago

What is the ID of your outdoor temp sensor in Domoticz ?

ocmeros commented 2 years ago

The ID of the sensor in Domoticz is 2956.

`

!/bin/bash

fetch outside temp (use jq to parse JSON object correctly)

TEMP=curl -s "http://127.0.0.1:8080/json.htm?type=devices&rid=2956" | jq '.result[0].Temp'

post using curl to API

curl -s -H "Content-Type:application/json" -d "OK" http://192.168.2.21/api/v1/otgw/command/OT=$TEMP ` I also just did a tcpdump on my odroid, and I capture the following message:

15:33:12.303011 IP odroid.home.60844 > otgw.home.http: Flags [P.], seq 1:156, ack 1, win 29200, length 155: HTTP: POST /api/v1/otgw/command/OT=4.8 HTTP/1.1 15:33:12.314155 IP otgw.home.http > odroid.home.60844: Flags [P.], seq 1:84, ack 156, win 1989, length 83: HTTP: HTTP/1.1 200 OK

So I looks like the correct url was send and an OK reply was returned, but no value on the OTGW web interface or thermostat.

arjanwaard commented 2 years ago

Only thing I can think of that to have the temperature visible you need an unsupported code in the exchange so the OTGW can replace that code with the temperature code.

Xenomes commented 2 years ago

If you change the last line in to curl -X PUT http://otgw.local/api/v1/otgw/command/OT=$TEMP it could work, you can change otgw.local to you ip address if needed. Also check if the url in line four is working.

JerJon commented 2 weeks ago

If you change the last line in to curl -X PUT http://otgw.local/api/v1/otgw/command/OT=$TEMP it could work, you can change otgw.local to you ip address if needed. Also check if the url in line four is working.

It worked, but I have to use TO for Outside Temperature instead of OT