http plugin?

Posted on
Thu Aug 12, 2021 11:00 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

http plugin?

In the Announcement for 2021.1, Jay wrote:
  • Added the ability for plugins to handle arbitrary HTTP requests.

So, I was wondering if anyone (Flying Diver?) was thinking about something like an http virtual device plugin. The idea would be to create an Indigo device for which the state was maintained by http requests from some arbitrary external system. A lot like the REST API. Except, there would be the possibility of some degree of communicating back to the external service. Though obviously only synchronous with receipt pf requests, and there would probably need to be a message queue. . Also, it would be possible to define and manipulate device states.

This might end up being functionally similar to updating variables via the REST API and then triggering some action 0ff of the variable's change. So, maybe it isn't really worth the effort.

But, just wondering.

Posted on
Fri Aug 13, 2021 6:07 am
FlyingDiver offline
User avatar
Posts: 7210
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: http plugin?


joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Aug 14, 2021 10:38 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: http plugin?

FlyingDiver wrote:

Thanks. Yes, I had forgotten about that plugin. I had used it previously as the basis for a sprinkler control system. Just a small hack to return an ACK or a NAK depending on various conditions.

One question though. The plugin description says
...The first "action" the plugin supports is "/setvar". This will set the specified variables to the values given. ...
But, instead, the plugin actually creates and up[dates states of the Indigo device. That is actually what I'd want. Just not what the plugin says it does. Did you forget to update the description when you released httpd2?

So, the only thing really missing from the functionality I described in my first post in this thread is the ability to create a custom response. Perhaps a dynamic string or the results of some arbitrary script execution. The first one should be pretty straightforward, the second idea not as much.

But, in any case, thanks!

Posted on
Sat Aug 14, 2021 10:39 am
FlyingDiver offline
User avatar
Posts: 7210
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: http plugin?

berkinet wrote:
One question though. The plugin description says
...The first "action" the plugin supports is "/setvar". This will set the specified variables to the values given. ...
But, instead, the plugin actually creates and up[dates states of the Indigo device. That is actually what I'd want. Just not what the plugin says it does. Did you forget to update the description when you released httpd2?


Yes. The description is out of date. :(

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Aug 15, 2021 4:19 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: http plugin?

So... I have switched two devices from the REST API to the HTTPd 2 plugin. These devices are actually scales. One measures the weight of a butane tank the other the weight of mail, etc. in our mailbox.

While doing this I thought it would be nice to see the weight in the Display State column in the devices table. So, I offer the following hack (I.e. quickly coded and tested only to see if it does what I wanted).

In devices Devices.xml I added this property to the HTTP/HTTPS Server device:
Code: Select all
            <Field id="displayState" type="textfield"  defaultValue="">
                <Label>Display state for devices list:</Label>
            </Field>

Then, I added this metrhod under callback for state list changes in plugin.py:
Code: Select all
    def getDeviceDisplayStateId(self, device):
        states_list = device.states
        displayState = device.pluginProps.get('displayState', None)
        if displayState in states_list:
            return displayState
        else:
            return None

Posted on
Sun Aug 15, 2021 6:08 am
FlyingDiver offline
User avatar
Posts: 7210
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: http plugin?

You could do a pull request in GitHub.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests