Rules not working and "how to send data to 3rd party"

Moderators: Voyager, BertB, rtenklooster, Stuntteam, grovkillen, TD-er

Post Reply
Message
Author
jverdicchio
Normal user
Posts: 4
Joined: 06 Nov 2018, 10:44

Rules not working and "how to send data to 3rd party"

#1 Post by jverdicchio » 06 Nov 2018, 11:45

Firstly, a new comer to this forum. The posts look really useful and I enjoy reading them.
I have a Sonoff TH16 that I've flashed with "ESP_Easy_mega-20181105_normal_ESP8266_1024.bin".
Attached is a temperature/humidity gauge "Environment - DHT11/12/22 SONOFF2301/7021" .
On the single relay I have a 2kW fan heater.

The temperature and humidity are correctly displayed in the "devices" section.
I can happy turn the heater on/off from either the tools command "GPIO,12,[0,1]" or via a web request "http://sonoff_ip_address/control?cmd=gpio,12,0"

I ideally want to be able to sent the temperature being measured by the Sonoff to my Loxone home automation system. This is my existing control for my lighting, heating, etc. The Loxone can then make decisions about what temperature the office should be and control the heater.

My initial thought was to use a rule with SendToHTTP i.e.
on OfficeTemp#Temp do
SendToHTTP userId:passwd@loxone_ip_address,80,/dev/sps/io/OfficeTemp/[OfficeTemp#Temp]
SendToHTTP laptop_ip_address,8001,/control?cmd=7dt,[OfficeTemp#Temp]
endon

where userId, passwd, loxone_ip_address and laptop_ip_address would be the actual account, password and ip address of my Loxone box. OfficeTemp is the name I've given to the output of the gauge in the devices section . I've checked in the log and can see I must be going something correct as I see this

60325492: DHT : Temperature: 26.70
60325492: DHT : Humidity: 49.00
60325495: EVENT: OfficeTemp#Temp=26.70
60325516: ACT : SendToHTTP xxx:yyy@zzz,80,/dev/sps/io/OfficeTemp/26.7
60325533: ACT : SendToHTTP vvvv,8001,/control?cmd=7dt,26.7
60325553: EVENT: OfficeTemp#Humidity=49.00

Where xxx, yyy,zzz and vvvv are all correct. and the number is the current temperature being displayed on my devices. My problem is I can not tell what is actually being sent to my Loxone box. If I use "Postman" and "post" a command like this
http://userId:passwd@loxone_ip_address/dev/sps/io/OfficeTemp/23
My Loxone box does indeed show 23 in the OfficeTemp. However, this SendToHTTP is not having the same affect and no value is being received.

I added the second SendToHTTP call to my laptop so I could see what was coming in via wireshark.
2018-11-06_1030.png
2018-11-06_1030.png (194.54 KiB) Viewed 369 times
There doesn't appear to be a http request in here at all (filtered to only show ip from sonoff_ip_address.

So, to have a temporary solution to this I'd thought I could use a rule to turn the heater on and off when some hard-coded limits were reached.
So, another rule
on [OfficeTemp#Temp] < 18.0 do
GPIO,12,1
endon
and a 3rd rule
on [OfficeTemp#Temp] > 20.0 do
GPIO,12,0
endon

These rules do not appear to trigger at all no matter how hot or cold it gets.

I'm sure this is newbie stupidity but I can't see it.

User avatar
grovkillen
Normal user
Posts: 2585
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules not working and "how to send data to 3rd party"

#2 Post by grovkillen » 06 Nov 2018, 11:58

First of all. THANKS for being a newcomer :)

I'm not really sure that giving the password/user id is part of the scope for the SendHTTP command. But the the later code is incorrect. Please read the tutorial guides here: https://www.letscontrolit.com/wiki/inde ... rial_Rules

In short, this should be the correct rule for internally controlling the fan:

Code: Select all

on OfficeTemp#Temp do
 if [OfficeTemp#Temp] < 18.0
  GPIO,12,1
  endif
  if [OfficeTemp#Temp] > 20.0
    GPIO,12,0
   endif
endon
But you should look into the regulator plugin and see if that one fits your needs.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

jverdicchio
Normal user
Posts: 4
Joined: 06 Nov 2018, 10:44

Re: Rules not working and "how to send data to 3rd party"

#3 Post by jverdicchio » 09 Nov 2018, 16:54

Thanks grovkillen for the rules correction and the use of "Regulator plugin". That appears to work as my office is no longer cold! It tool a little while to realise that plugins are reached through the "devices" section and are some of the entries in the pull-down - Wiki talks about plugins but not where to find them in the GUI.

There is an option in the Regulator plugin to talk to a controller. If I select a generic HTTP controller and set one up I still can't get any notification to my Loxone box. I think people have asked on this forum before but I haven't seen an actual answer. So, my outstanding question is: How to send data via http to a 3rd party:

I need to send a message that looks like this:
http://userId:passwd@loxone_ip_address/dev/sps/io/OfficeTemp/a_number

I know this works, as using a program like postman does indeed show the correct number in my Loxone screen for OfficeTemp

User avatar
grovkillen
Normal user
Posts: 2585
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules not working and "how to send data to 3rd party"

#4 Post by grovkillen » 09 Nov 2018, 17:09

I'm not up to date with the generic http controller. Must look into that.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
iron
Normal user
Posts: 67
Joined: 24 Sep 2016, 08:37
Location: Veria, Greece
Contact:

Re: Rules not working and "how to send data to 3rd party"

#5 Post by iron » 10 Jan 2019, 11:17

grovkillen wrote:
09 Nov 2018, 17:09
I'm not up to date with the generic http controller. Must look into that.
Being able to pass user_name / password in the SendtoHttp will make a nice "MQTT to HTTP gateway" in the Rules, for devices within the network that do not support MQTT

-D
-D

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests