Send GET driving me crazy

I can not figure out why my Send GET does not work within RM but if I copy the GET action defined in the same rule and paste it into a browser it works fine. Here is the url defined

http://192.168.1.194/Dev/stLogger.php?devID=HotTub&fName=Hottub&ext=csv&srtOrder=0&logMsg=%msg%

This is the rule


Set HotTubTemp to Hot Tub Temperature(104.6)
Set OutsideTemp to Backyard Tower Temperature(15.5)
Set var_PowerLevel to Iota_HotTub Power meter(148.3)
Set msg to '%date%,%time%,%value%,%HotTubTemp%,%OutsideTemp%
(2022-05-08,11:26,148.3,104,15
)'
IF (Power level of Iota_HotTub27(4.0) is > 12.0(F)  AND 
Power level of Iota_HotTub27(4.0) is < 100.0(T) [FALSE]) THEN
	Exit Rule
END-IF
Disabled: IF (Power level of Iota_HotTub27(4.0) is > 500.0(F)  AND 
Private Boolean(false) is true(F) [FALSE]) THEN
	Disabled: Notify Pushover Home Alert: 'Hot Tub Switched to Heating Mode'
	Disabled: Set Private Boolean(false) False
Disabled: ELSE-IF (Power level of Iota_HotTub27(4.0) is <= 500.0(T)  AND 
	Private Boolean(false) is false(T) [TRUE]) THEN
	Disabled: Set Private Boolean(false) True
	Disabled: Notify Pushover Home Alert: 'Hot tub has finished heating'
Disabled: END-IF
Send GET to:  http://192.168.1.194/Dev/stLogger.php?devID=HotTub&fName=Hottub&ext=csv&srtOrder=0&logMsg=%msg%( http://192.168.1.194/Dev/stLogger.php?devID=HotTub&fName=Hottub&ext=csv&srtOrder=0&logMsg=2022-05-08,11:43,147.4,104,16
)

Here is the log output when the Actions are run

app:3402022-05-08 11:44:39.061 am infoAction: Send GET to:  http://192.168.1.194/Dev/stLogger.php?devID=HotTub&fName=Hottub&ext=csv&srtOrder=0&logMsg=%msg%( http://192.168.1.194/Dev/stLogger.php?devID=HotTub&fName=Hottub&ext=csv&srtOrder=0&logMsg=2022-05-08,11:44,147.7,104,16                                                                                               )
app:3402022-05-08 11:44:39.042 am infoAction: END-IF
app:3402022-05-08 11:44:39.040 am infoAction:     Exit Rule (skipped)
app:3402022-05-08 11:44:39.037 am infoAction: IF (Power level of Iota_HotTub27(4.0) is > 12.0(F) AND 
                                                                                               Power level of Iota_HotTub27(4.0) is < 100.0(T) [FALSE]) THEN (skipping)
app:3402022-05-08 11:44:38.936 am infoAction: Set msg to '%date%,%time%,%value%,%HotTubTemp%,%OutsideTemp%
                                                                                               (2022-05-08,11:44,147.7,104,16
                                                                                               )'
app:3402022-05-08 11:44:38.908 am infoAction: Set var_PowerLevel to Iota_HotTub Power meter(147.7)
app:3402022-05-08 11:44:38.888 am infoAction: Set OutsideTemp to Backyard Tower Temperature(16.3)
app:3402022-05-08 11:44:38.867 am infoAction: Set HotTubTemp to Hot Tub Temperature(104.6)
app:3402022-05-08 11:44:38.020 am infoTriggered

The log output shows that the send Get was executed but it somehow failed to either get to the .php file or the data was corrupted. As I said above, you can copy the url in the log output, paste into a browser and it works fine.

Appears to me that the %msg% is not being substituted in the Send command (and perhaps not in the 'Set msg' either.) Try an easy test. Maybe just log 'msg' contents first.

The msg is being substituted if you look (and scroll way to the right) at the last line in the rule.

( http://192.168.1.194/Dev/stLogger.php?devID=HotTub&fName=Hottub&ext=csv&srtOrder=0&logMsg=2022-05-08,11:43,147.4,104,16
)

That said, I have tried removing %msg% all together and hard coding the url with a made up msg.
i.e &logMsg=ThisHasNoSpaces Made no difference. Very puzzling

If you look at the 'Send' line , it is not interpolated like your hand crafted. I strongly suspect you need to escape some character. I'm not the right person for rule machine and its escaping rules but there are plenty to problems and solutions similar to yours that you can search for.

You are not looking far enough down the line. Look to the right of the Send line and inside the brackets you will see what the SEND is translated to. Same with the Set MSG line. Inside the brackets are what the line is translated to.

Just for giggles, remove the commas in the url. Even better, if you have access to the http server logs you can tell what it thinks of the request.

Or send it to a mock server like beeceptor to see what it receives.

It never even reaches the server however.........

I took the same rule and installed it on my other hub. Bingo... works fine
I went back to my first hub a created a very simple rule to send a message to EventGhost
The action is:
Send GET to: 192.168.1.231:88/?TestThisMessage

EG never receives the event. Same rule on the other hub works fine.

I rebooted the hub but the problem persists. I checked my other rules that use Send and only those that send to the other hub which uses MakerApi work. In the reverse, the same rules from the culprit hub work fine on the other hub. Makes no sense to me.

Something is amiss on this one hub but I can't figure out what. I am pretty sure this problem is new. Both hubs are on the same FW version.

Sounds more like a firewall or routing issue...

I just "duplicated" this process with a small SmartApp and it works fine. Here is part of the app

def subscribeToEvents() {
	subscribe(mySwitch, "switch", switchHandler)
}


def switchHandler(evt) {
    log.debug "Switch triggered"
    sendHubCmd()
    
}
def sendHubCmd() {  // Redirect WAN messages to EG. 
   def lanIP = egServer  // In this case the IP = 192.168.1.194
    
    def formattedParameters="/Dev/stLogger.php?fName=HotTub/Hottub&logMsg=2022-05-09,07:59,6.1,100,9"
     sendHubCommand(new hubitat.device.HubAction(
            method: "GET",
            path: "/${formattedParameters}",
            headers: [ HOST: "${lanIP}" ]
        ) )
}

This is the same hub and same URL as I use in the Rule.

But why only on one hub but not the other? They re both sitting next to each other connected to the same lan.

Are you saying the app CAN get there from both hubs, but the rule can't, or something else?

Exactly. The rule on the other hand only works on one hub but not the other.

What happens if you change the app to send on port 88?

Not sure I understand that. The app works as it should for the complete URL I specified in the code. Is it the comments in the code throwing you off? The URL is pointing to a webserver .php file not EG as the comments in the code might suggest. If I add port 88 I am sure it will fail. On the other hand, if I were to change it to send a message to EG I would add port 88 to the IP. In this case, the app would (& does) work fine, the same Send in RM would (has) not work(ed) on one hub but work fine on the other.

What has puzzled me is that this problem appears new. The culprit hub does not have a lot going on as I use it mostly for testing. The latest change I have made is adding iotaWatt power by "Dan Ogorchock". I cant imagine how that would impact this rule but if I have to I'll disable it as a last resort

...because you said your rule was sending to IP 192.168.1.231 on port 88

Yup, things are getting a bit muddied because of all the different things I have been trying. Sorry about that.

The problem started with a rule that Send message to a webserver. php file. The webserver never received the message (nothing in access.log) . There was some question(s) about how the URL, specifically the %msg% was constructed. I therefore simplified the rule to send a message to EG (92.168.1.231 on port 88) . This simple rule did not work on this culprit hub but worked fine on the other. I then decided I would write the little SmartApp I posted above and see what it wqould do. This app uses the same URL (webserver with php) as in the original rule shown in my first post. The smartapp worked fine on both hubs.

I hope that this does not further muddy the issue.

Thanks, I just need my second cup of coffee to kick in...

2 Likes

Ok, I read back over this thread, and I don’t see any version info mentioned.

  1. What version of Rule Machine? I assume 5.1 (not Legacy). What is the version info at the bottom when you go to create a new Rule?

  1. What is the version info at the bottom of the good hub / bad hub rules?

RM Version 5.1.3 (4/4/2022) on both hubs.
Things got even more interesting. I exports the rule from the good hub, imported it into the culprit hub and, guess what? It worked.
Within the original rule when this all started, I deleted the SEND action and re-added it at the top. It worked the first time then stopped working. I deleted and re-created all variables and so far, all is working. Makes zero sense to me.

Going to play around a bit more and see if I can make it fail again.

1 Like

Download the Hubitat app