Transition from httpd2 to Reflector?
-
- Posts: 49
- Joined: Sun Mar 18, 2018 7:08 pm
Transition from httpd2 to Reflector?
I still have several httpd2 servers running that I am updating so that I can retire httpd2. There are few in question for my wireless tags where it uses the Wireless Tags url calling parameter to invoke as follows (https://xxxxx:xxxxx@indigo.xxxxxx.xxx:5x5x2/webhook-8x85x237?timevar={5}&tempvar={2}). This is currently working fine except it is using httpd2 servers / proxy (that I need to retire) in indigo to catch the parameters and fire off the python script.
In creating a reflector base alternative, I am able to use this command to write variables that the python script can handle: (curl -X POST -H "Authorization: Bearer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -d '{"message":"indigo.variable.updateValue","objectId": 338338399,"parameters":{"value":"test"}}' https://xxxxxxxx.indigodomo.net/v2/api/command)
Looking at the Wireless Tags interface, their implementation for using curl is somewhat sketchy and I cannot seem to get their interface to provide the valid POST configuration to emulate the curl command above.
Keep getting: 10/26-14:19:27Z:Starting URL Call External: https://xxxxxxxx.indigodomo.net/v2/api/indigo.variables ...10/26-14:19:27Z:URL Call for Tag: CC_Refrigerator, Event: update, Error: The remote server returned an error: (405) Method Not Allowed.
Does anyone have a quick tip for a simple HTTPS url type command that I could use in the Wireless Tags url calling interface that can pass their variables to indigo variables? CURL parameter combinations don't seem to be a great working option in their interface.
Also open to any other thoughts that the community may see and advise along these lines.
In creating a reflector base alternative, I am able to use this command to write variables that the python script can handle: (curl -X POST -H "Authorization: Bearer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -d '{"message":"indigo.variable.updateValue","objectId": 338338399,"parameters":{"value":"test"}}' https://xxxxxxxx.indigodomo.net/v2/api/command)
Looking at the Wireless Tags interface, their implementation for using curl is somewhat sketchy and I cannot seem to get their interface to provide the valid POST configuration to emulate the curl command above.
Keep getting: 10/26-14:19:27Z:Starting URL Call External: https://xxxxxxxx.indigodomo.net/v2/api/indigo.variables ...10/26-14:19:27Z:URL Call for Tag: CC_Refrigerator, Event: update, Error: The remote server returned an error: (405) Method Not Allowed.
Does anyone have a quick tip for a simple HTTPS url type command that I could use in the Wireless Tags url calling interface that can pass their variables to indigo variables? CURL parameter combinations don't seem to be a great working option in their interface.
Also open to any other thoughts that the community may see and advise along these lines.
- jay (support)
- Site Admin
- Posts: 18479
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Transition from httpd2 to Reflector?
Where is this coming from:
Perhaps step back and explain it from a higher level (without any httpd2 specifics).
And where is it getting called from? I'm a little unclear on what executing what...Keep getting: 10/26-14:19:27Z:Starting URL Call External: https://xxxxxxxx.indigodomo.net/v2/api/indigo.variables ...10/26-14:19:27Z:URL Call for Tag: CC_Refrigerator, Event: update, Error: The remote server returned an error: (405) Method Not Allowed.
Perhaps step back and explain it from a higher level (without any httpd2 specifics).
-
- Posts: 49
- Joined: Sun Mar 18, 2018 7:08 pm
Re: Transition from httpd2 to Reflector?
Hello Jay,
In the current httpd2 setup, the initiation / call is started from the WirelessTag web site. They have a panel where you can specify a URL that is called for any events that occur with the sensors. This panel calls the website specified and passes available vars from the WirelessTag device. In this case, this is where the
https://xxxxx:xxxxx@indigo.xxxxxx.xxx:5x5x2/webhook-8x85x237?timevar={5}&tempvar={2}) resides.
The first part is the https call to the httpd2 indigo server and the two vars being parsed are the time and temp from the WirelessTag device.
Best regards,
Dean
In the current httpd2 setup, the initiation / call is started from the WirelessTag web site. They have a panel where you can specify a URL that is called for any events that occur with the sensors. This panel calls the website specified and passes available vars from the WirelessTag device. In this case, this is where the
https://xxxxx:xxxxx@indigo.xxxxxx.xxx:5x5x2/webhook-8x85x237?timevar={5}&tempvar={2}) resides.
The first part is the https call to the httpd2 indigo server and the two vars being parsed are the time and temp from the WirelessTag device.
Best regards,
Dean
- jay (support)
- Site Admin
- Posts: 18479
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Transition from httpd2 to Reflector?
Ah, ok, I see the issue. The HTTP API uses HTTP POST commands and from what you are showing the wireless tag website is using an HTTP GET. Check the documentation or help system for it to see if there is some way to create a POST rather than a GET.
- jay (support)
- Site Admin
- Posts: 18479
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: Transition from httpd2 to Reflector?
A quick glance at their website shows they have an IFTTT integration - which you probably could use to catch events from their devices and POST to the HTTP API.
It also appears that you can write scripts in JavaScript that will run on their side which they call KumoApps. There's a httpCall function which supports POST requests.
It also appears that you can write scripts in JavaScript that will run on their side which they call KumoApps. There's a httpCall function which supports POST requests.
-
- Posts: 49
- Joined: Sun Mar 18, 2018 7:08 pm
Re: Transition from httpd2 to Reflector?
Thanks for the suggestions, Jay.
There is a post function available as an option on their web portal, but I have not been successful in getting the right parameter combinations for it to work. I keep getting the 405 errors back from the reflector when I use their post option.
The JavaScript with httpCall looks promising. I am not real keen with JavaScripting, so this may be a bit of challenge. I will explore their documentation further and play around in that direction.
It appears they may also have a a full API that supports curl.... so I may be able to just tweak the python scripts and pull the variables directly through their API regularly, rather than pushing the variables through their interface when a change event occurs, (if I can get an oauth key established with my account).
Thanks again for pointing these options out. I overlooked what functions they had available. I had only used their web interface up to this point.
Best regards,
Dean
There is a post function available as an option on their web portal, but I have not been successful in getting the right parameter combinations for it to work. I keep getting the 405 errors back from the reflector when I use their post option.
The JavaScript with httpCall looks promising. I am not real keen with JavaScripting, so this may be a bit of challenge. I will explore their documentation further and play around in that direction.
It appears they may also have a a full API that supports curl.... so I may be able to just tweak the python scripts and pull the variables directly through their API regularly, rather than pushing the variables through their interface when a change event occurs, (if I can get an oauth key established with my account).
Thanks again for pointing these options out. I overlooked what functions they had available. I had only used their web interface up to this point.
Best regards,
Dean
-
- Posts: 49
- Joined: Sun Mar 18, 2018 7:08 pm
Re: Transition from httpd2 to Reflector?
I got a python script version working that updates the indigodomo variables from the tags as needed. I do have a lingering warning on the indigo log when the curl command is executed.
Web Server Warning HTTP API v2 POST command received, id: '- no message id -' from 'xx.xxx.xx.xxx'
This is format of the curl command that I am executing:
curl -X POST -H "Authorization: Bearer xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" -d '{"message":"indigo.variable.updateValue","objectId": xxxxxxxxxx,"parameters":{"value":"test2"}}' https://xxx.ixxxxxo.net/v2/api/command
I see this in the response to the curl command from my terminal session when I execute this manually: {"success":"message sent to the Indigo Server, check the Event Log for details","id":"- no message id -"}
What is the API expecting for the messageID to be passed? Is there some online doc that defines the parameter that I am missing on this command?
Web Server Warning HTTP API v2 POST command received, id: '- no message id -' from 'xx.xxx.xx.xxx'
This is format of the curl command that I am executing:
curl -X POST -H "Authorization: Bearer xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" -d '{"message":"indigo.variable.updateValue","objectId": xxxxxxxxxx,"parameters":{"value":"test2"}}' https://xxx.ixxxxxo.net/v2/api/command
I see this in the response to the curl command from my terminal session when I execute this manually: {"success":"message sent to the Indigo Server, check the Event Log for details","id":"- no message id -"}
What is the API expecting for the messageID to be passed? Is there some online doc that defines the parameter that I am missing on this command?
-
- Posts: 49
- Joined: Sun Mar 18, 2018 7:08 pm
Re: Transition from httpd2 to Reflector?
Playing around with this a bit further and was able to see that by defining an "id" in the curl command, that it will pass this value to the logs. Is this intended purpose for this filed to be passed to the log as a warning message? Is there a way to make a log message without being at the warning level?
Log messages:
Web Server Warning HTTP API v2 POST command received, id: 'Update for cc_fridge_temp at 2024-11-26 10:58:24' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for cc_fridgetemp_time at 2024-11-26 10:58:25' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for cc_freezer_temp at 2024-11-26 10:58:25' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for cc_freezertemp_time at 2024-11-26 10:58:25' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for tanktemp at 2024-11-26 10:58:25' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for tanktemp_time at 2024-11-26 10:58:26' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for dp_freezer_temp at 2024-11-26 10:58:29' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for dp_freezertemp_time at 2024-11-26 10:58:30' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for dp_fridge_temp at 2024-11-26 10:58:30' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for dp_fridgetemp_time at 2024-11-26 10:58:30' from '98.245.62.192'
*** Function:
Function to update an Indigo Domo variable
def update_indigo_variable(object_id, value, message_id="WirelessTag Python Script Execution"):
"""
Updates an Indigo Domo variable with the specified value.
"""
headers = {
"Authorization": f"Bearer {INDIGO_API_TOKEN}",
"Content-Type": "application/json"
}
data = {
"message": "indigo.variable.updateValue",
"objectId": object_id,
"parameters": {
"value": str(value)
},
"id": message_id
}
try:
response = requests.post(INDIGO_API_URL, headers=headers, json=data)
response.raise_for_status()
print(f"Indigo variable updated: Object ID {object_id}, Value {value}")
except requests.exceptions.HTTPError as err:
print(f"HTTP Error updating Indigo variable: {err}")
except Exception as e:
print(f"Error updating Indigo variable: {e}")
Log messages:
Web Server Warning HTTP API v2 POST command received, id: 'Update for cc_fridge_temp at 2024-11-26 10:58:24' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for cc_fridgetemp_time at 2024-11-26 10:58:25' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for cc_freezer_temp at 2024-11-26 10:58:25' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for cc_freezertemp_time at 2024-11-26 10:58:25' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for tanktemp at 2024-11-26 10:58:25' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for tanktemp_time at 2024-11-26 10:58:26' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for dp_freezer_temp at 2024-11-26 10:58:29' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for dp_freezertemp_time at 2024-11-26 10:58:30' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for dp_fridge_temp at 2024-11-26 10:58:30' from '98.245.62.192'
Web Server Warning HTTP API v2 POST command received, id: 'Update for dp_fridgetemp_time at 2024-11-26 10:58:30' from '98.245.62.192'
*** Function:
Function to update an Indigo Domo variable
def update_indigo_variable(object_id, value, message_id="WirelessTag Python Script Execution"):
"""
Updates an Indigo Domo variable with the specified value.
"""
headers = {
"Authorization": f"Bearer {INDIGO_API_TOKEN}",
"Content-Type": "application/json"
}
data = {
"message": "indigo.variable.updateValue",
"objectId": object_id,
"parameters": {
"value": str(value)
},
"id": message_id
}
try:
response = requests.post(INDIGO_API_URL, headers=headers, json=data)
response.raise_for_status()
print(f"Indigo variable updated: Object ID {object_id}, Value {value}")
except requests.exceptions.HTTPError as err:
print(f"HTTP Error updating Indigo variable: {err}")
except Exception as e:
print(f"Error updating Indigo variable: {e}")
Re: Transition from httpd2 to Reflector?
The Indigo HTTP API has a command class that was added with Indigo 2023.2 that allows you to send log message to the server. There's a full example here:
https://wiki.indigodomo.com/doku.php?id ... nd_message
The warning messages are intentional and considered a security feature. That said, you can silence them using the Advanced Web Server Settings dialog, but it's all or nothing with that setting. That will allow you to send messages to the log without the security messages.
https://wiki.indigodomo.com/doku.php?id ... nd_message
The warning messages are intentional and considered a security feature. That said, you can silence them using the Advanced Web Server Settings dialog, but it's all or nothing with that setting. That will allow you to send messages to the log without the security messages.
Code: Select all
Web Server Warning HTTP API v2 POST command received, id: 'optional-user-generated-id' from '173.22.173.130'
Web Server Some important log message goes here.
I came here to drink milk and kick ass....and I've just finished my milk.
My Plugins and Scripts
My Plugins and Scripts
-
- Posts: 49
- Joined: Sun Mar 18, 2018 7:08 pm
Re: Transition from httpd2 to Reflector?
Got it. Turning everything off does not seem like a great idea. ... I will let them be as warnings in the spirit of security. I appreciate the insights and the pointer to the documentation.
Best regards ....
Best regards ....