SOLVED: How to use cgi temperature output Foscam to update virtual sensor?

Moderator: leecollings

Post Reply
Bram81
Posts: 22
Joined: Saturday 02 May 2015 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Utrecht, NL
Contact:

SOLVED: How to use cgi temperature output Foscam to update virtual sensor?

Post by Bram81 »

Hi,

I've recently bought a Fosbaby IP Camera to be used in a babyroom. One of it's features is that is has a Temperature sensor. In the WebUI you can set a minimum and maximum temperature so an alert can be sent if the current temperatue is out of that range. Now I would like to use the current temperaature to update a virtual sensor in Domoticz so if for example the room temp is below 15 degrees C I can turn on the heating system for a while.

I've managed to find an url which cam show me the current temperature: http://192.168.2.12:88//cgi-bin/CGIProx ... xx&pwd=xxx

which gives me the folowing result:

<CGI_Result>
<result>0</result>
<state>1</state>
<degree>18</degree>
</CGI_Result>

So i'm looking for a way to post the <degree> value to (I guess a JSON URL) to update a virtual sensor. Is there anyone who can put me on the right track?
Bram81
Posts: 22
Joined: Saturday 02 May 2015 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Utrecht, NL
Contact:

Re: SOLVED: How to use cgi temperature output Foscam to update virtual sensor?

Post by Bram81 »

For those who might be interested. To get the current temperature measured by the temperature sensor of the FosBaby and use that value to update a virtual temperature sensor in Domoticz I use the folowing bash-script which runs every minute through a crontab.

Code: Select all

#!/bin/bash
content=$(curl "http://FOSCAM_IP:PORT//cgi-bin/CGIProxy.fcgi?cmd=getTemperatureState&usr=<username&pwd=<password>")
echo $content
x=$(curl -L "http:///FOSCAM_IP:PORT//cgi-bin/CGIProxy.fcgi?cmd=getTemperatureState&usr=<username&pwd=<password>" | sed -n "/<degree>/,/<\/degree>/p")
temp=$(echo $x | grep -o '[0-9]*')
curl -s "http://DOMOTICZ_IP:8080/json.htm?type=command&param=udevice&idx=<IDX_SENSOR>&nvalue=$temp&svalue=$temp" &
exit 0

geezerrr
Posts: 79
Joined: Tuesday 02 December 2014 22:16
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: SOLVED: How to use cgi temperature output Foscam to update virtual sensor?

Post by geezerrr »

Hi Bram81,
Thats cool!! I use a Motorola baby cam which have a temp sensor as well. I was looking for a way to processing these values into donoticz. Your script will be a good starting point for me! Thnx
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest