ALTUI & DataStorage Providers

[quote=“sle118, post:20, topic:190668”]I’ve been trying to setup a local instance of emoncms and I’m scratching my head on setting it up as a valid data provider.

First, I have created a copy of function sendValueToStorage_emoncms to sendValueToStorage_Local_emoncms, changed the url to point to the local instance, and defined it in the startup lua script.

Next, from the examples in this thread, I ran the following code in the “test lua”

[code]local json_loc = require “openLuup.json”
local newJsonParameters = {
callback = “sendValueToStorage_Local_emoncms”,
parameters = {{
default = 1,
key = “nodeid”,
label = “Node ID”,
type = “number”
},{
key = “feedid”,
label = “Feed ID”,
type = “number”
},{
key = “999999999222222222233333334444474”,
label = “Input Key name”,
type = “text”
},{
key = “999999999222222222233333334444476”,
label = “Read/Write API Key”,
type = “text”
},{
default = “http://127.0.0.1/emoncms/vis/editrealtime?feedid={1}&embed=1&apikey={3}”,
ifheight = 460,
key = “graphicurl”,
label = “Graphic Url”,
type = “url”
}},
url = “”
}
local arguments = {
newName = “emoncms_local”,
newUrl = “”,
newJsonParameters = json_loc.encode (newJsonParameters),
}

luup.call_action (“urn:upnp-org:serviceId:altui1”, “RegisterDataProvider”, arguments, AltUI)
[/code]

I was hoping to have a new data provider template added with all the defaults (and the keys). Although I now see the new data provider, I am simply unable to have the api keys “stick” in place…

I have since updated the code above. The keys had to be placed in the “key” elements of the structure; doing this resolved my initial issue. The next thing I found is that ALTUI does not save the callback parameters in the json. I was hoping a “set and forget” where I would run the code and let ALTUI restore the values when the luup engine is restarted, but that didn’t work as expected. The reason seems to be that the callback and callback names are decoupled in a separate lookup which gets constructed only when they are fully registered.

So I forked the code and added some logic to get an actual function added to the callback table if the function is found in the global table. Then I created a new pull request after testing it successfully in my own system.
https://github.com/amg0/ALTUI/pull/2[/quote]

in fact I did not support calling directly another LUA function which comes from a code I do not know ( cannot trust ). so only ALTUI internally calls a function to push to thingspeak or emoncms, but externally registered data providers using the UPNP action works exclusively with the url mecanism. The data provider must provide a url ( like a handler url if your data provider is a lua device ) that ALTUI will call with a wget() passing in argument all the data providers provided parameters in the json structure as well as lul_device lul_service lul_variable old new lastupdate values

your code is working fine but a) it poses a little supportability threat to me as ALTUI would call unknown code in its own lua space and b) I am not sure I understand fully the part of recursively searching inside the _G table, can you please explain that part a little bit ?

I don’t follow this exactly, either, and not sure I see the need. The Data Storage Provider mechanism for additional providers works as advertised (the DataYours plugin uses it) and, under openLuup (which you seem to be) the HTTP request to a localhost get routed directly to the local plugin, so it’s actually very efficient (or, at least, not inefficient.)

If, for some reason, this doesn’t work with your local emoncms instance, you could, nevertheless, use it with a small piece of code that acts as a proxy to your local instance.

I realize my post wasn’t really clear.

I setup a local openLuup to do what others are doing: offloading plugin processing, etc on a more powerful box (thanks for your efforts!). Then I wanted to get a local instance of emoncms as I like reducing reliance on external services for this type of things. Within ALTUI, there is already a default provider which was created for emoncms, but it is actually pointing to the the outside world and I wanted to :

[ul][li]Point to local emoncms instance [/li]
[li]Default API Keys when “pushing to” data provider[/li][/ul]

In order to achieve this, I did the following

[ul][li]Copy the data provider “push” function and change it slightly[/li]
[li]Define that new function in the lua startup section[/li]
[li]Bind this new function to a data provider[/li][/ul]

I didn’t want to write a plugin for this, I have never tried and have the belief that it’s very complicated (probably not that much but anyhow). Everything seemed to be just fine in my code and implementation until I realized that ALTUI’s implementation of the provider uses a mechanism to store and retrieve providers. The idea is that when the providers are loaded from the existing json, callback functions are not loaded in the callback lookup table and therefore these callbacks need to be re-registered at every start by code rather than being reloaded from save.

I’m going to review my pull request and likely come back with something along these lines

local function _loadDataProviders() local str = luup.variable_get(ALTUI_SERVICE, "DataStorageProviders", lul_device) or "{}" DataProviders = json.decode(str) for k,v in pairs (DataProviders) do if (v["callback"] ~= nil) local callback_fn = table_search(_G,DataProviders[provider]["callback"],"",0) if callback_fn ~= nil then DataProvidersCallbacks[DataProviders[provider]["callback"]] = callback_fn end end end end

I ended up closing my pull request and opening a new one, which has an enhanced implementation of “_loadDataProviders”, which is where providers are loaded. If the PR is merged, ALTUI will be able to grab data providers defined in the lua startup script, which was my original intent.

see PR

Hello Sle118
thanks for this proposal, I am going to look at it to consider an integration

Question : where did you test this ? on openluup only or also on VERA ? thx

I would appreciate some help with this. I need really basic instructions. I created an account at emoncms.org and there I can see a write API key & a read API key.

If I go to my AL HEM in AltUI I go to variables and click the icon for “push to”. I check the box to enable pushing data to emoncms and I see the 5 things needing input.

The first is Node ID and that’s the node ID from my HEM that is listed as altid in Vera UI7 right?

The second is the Feed ID. It wants a number here. A assume that’s whatever number I want to have emon use right?

The third one is Input Key Name. Is this just what I want to name it or is it urn:schemas-micasaverde-com:device:PowerMeter:1 as listed for device type in Vera, or something else?

The next one is Read/Write API. The thing is, I have one for each on my emoncms account page so?

Finally the Graphic Url. It has this showing: http://emoncms.org/vis/editrealtime?feedid={1}&embed=1&apikey={3}. I don’t know if that’s set up correctly as-is or if I’m suppost to edit it with my API key or what?

Hi, amg0.
I need help.
I’m only a week, I bought VeraEdge and only understand it. I installed your plugin ALTUI and trying to figure out how to send data to the emoncms. Emoncms I have installed locally on my server Synology.

Now I have installed on Synology: OpenRemote application and AeonLab Zwave stick S2 and different zwave devices. Data sent from OpenRemote to Emoncms in this way:

</bean>

  <bean id = "rrd4jLogger" class = "org.openremote.controller.statuscache.rrd4j.Rrd4jDataLogger" />
  <bean id = "emonCMSLogger" class = "org.openremote.controller.statuscache.emoncms.EmonDataLogger" >
    <property name="emonURL" value="http://192.168.1.7/emoncms/input/post.json?&amp;apikey=5f51ed68e223863187f53820f6******&amp;node=20&amp;json=" />
    <property name="sensors">
      <list>
      	<value>NET_TEMPERATURE_SENSOR</value>
        <value>NET_PRESSURE_SENSOR</value>
	<value>NET_HUMIDITY_SENSOR</value>
        <value>FIBARO_S_SMOKE_AIR_TEMPERATURE_SENSOR</value>
	<value>FIBARO_S_MOTION_AIR_TEMPERATURE_SENSOR</value>
        <value>CH_TSTAT_AIR_TEMPERATURE_SENSOR</value>
	<value>AEO_HEM1_METER_SCALE_V_SENSOR</value>
        <value>AEO_HEM1_METER_SKALE_A_SENSOR</value>
	<value>AEO_HEM1_METER_SKALE_W_SENSOR</value>
        <value>AEO_HEM1_METER_SKALE_KWH_SENSOR</value>
	<value>NET_WIND_DIR_DEGREE_SENSOR</value>
	<value>NET_WIND_SPEED_SENSOR</value>
	<value>CH_AC_TSTAT_POWER_SCALE_WATT_SENSOR</value>
	<value>CH_AC_TSTAT_POWER_SCALE_WATT_OUT_SENSOR</value>
      </list>
    </property>
  </bean>

and resultat on screenshot.

I’m going to all the zwave devices to reconnect from AeonLab Zwave stick S2 to VeraEdge. Please tell me, how do I properly set up to send data from VeraEdge in a locally installed Emoncms? It is possible to customize to the send on http://192.168.1.7/emoncms ?
Thank.

  1. on the device variable dialogbox, click on the histogram icon to open the push config dialog
  2. enter parameters ( nodeid, feedid, inputkey, readwritekey ) , you can leave url as default.
  3. do not forget to click again the histogram bar to save the changes
  4. at every variable change, ALTUI will call http://emoncms.org/input/post.json?node=&json={:}&apikey=
  5. in variable watch page or in device variable page once you click the histogram you will be able to see the bar chart as rendered by emoncms

the url parameter can later on be customized to pass in your preferences in terms of zooming, period etc.

NOTE this is for internet emoncms. for local one there is no solution yet, you probably need to go through the dynamic registration and write a data provider plugin , until I look at this to see if I could offer another way. there are also some other data provider that akboer has written for instance using his Datayours solution I think. I have put a pointer on msg 1 of this thread to Datayours thread

Thanks for your reply.

And if in your plugin jast change path http://emoncms.org at http://192.168.1.7/emoncms? I have an account on emonsms.org, but would like to use locally, as it is now with OpenRemote.

Can you not achieve this in Startup Lua by registering the URL that you require? You’ll probably just need to name the storage provider differently from the pre-installed emoncms one.

I’m only the second week of trying to deal with VeraEdge. I assume you mean this:
http://forum.micasaverde.com/index.php?topic=35953.0

Sorry to be unclear. No, not that, but @amg0’s first post of this thread.

I am now releasing a beta for IFTTT integration as a data storage provider.
the beta is available as of now on github GitHub - amg0/ALTUI: Enhancement Interface for VERA home automation system

if you go to a particular device / variable and click on the histogram icon you can select a data storage provider. you can now select IFTTT
if you do so, you will have to enter 2 parameters
a) the Web Hook Key as given to you by IFTTT when you prepare the WebHook applet
b) the event name that you chose when you prepare the WebHook applet
do not forget to click on the histogram icon again to save your choices

then, in IFTTT you create a " if THIS then THAT" applet and select webhook as the THIS.
in terms of the THAT, you can chose what you want, for me I use google sheet such that I can record data in a google sheet. but tons of other kind of THAT actions are possible. very large set of possibilities.

IFTTT provides the concept of ingredients on the webhook applet and ALTUI will call the webhook service of IFTTT with the following elements ( which are decided by IFTTT, this is not a choice of ALTUI ) :

  • OccuredAt: the timestamp
  • Eventname : the event name you have chosen
  • value1: the altuiid of the VERA device sending the notification
  • value2: the string :
  • value3: the string :

in the THAT applet configuration , you can choose how to use the THIS input ingredients to perform the THAT action. in my google sheet example I just chose to add a new line to my spreadsheet

sample screen shots are attached to illustrate:

ALTUI & IFTTT integration tutorial

This step by step tutorial will guide you through the new ALTUI IFTTT integration to log in a google sheet any watched device variable changes.

[url=https://github.com/amg0/ALTUI/raw/master/Docs/IFTTT%20and%20VERA%20integration.pdf]https://github.com/amg0/ALTUI/raw/master/Docs/IFTTT%20and%20VERA%20integration.pdf[/url]

Multiple data providers

Starting with v 2.07.2270 , ALTUI will support one or more data output streams whenever a device’s variable changes.
The user interface to set this up will slighly change such that the user can really select one or several different data providers for a given variable.

That means it is now possible to send all data values changes to both a thingspeak graph , and an IFFF action for instance

Quick question. How does one delete the datastorage provider from a variable? Like if I configured the wrong variable? I can’t figure it out. :o

Unselect it from the menu list ( Ctrl click for multiple selection ), then close to save

That works. THANK YOU!!. I’m getting too old for this :-\ :-\ :-\ :-.

Hi,

Has any used webhooks to send a request BACK to Altui/Vera ? If so how have you done it ?

Thinking about an application to use a Google Home/Alexa number/name IFTTT ingredient to set a Vera multistring variable that could then be picked up by PLEG in due course. e.g. OK Google, set the ‘living room’ temperature to ‘22’

Any suggestions ?

David

AMG0,

Do you have any ideas on how to configure ALTUI to pass the value of a switch position/variable through to Webhooks ?

I’ve got a very clonky and non-elegant work around using PLEG but thought I’d ask if there’s a more direct/seamless way with ALTUI that you’ve discovered…

Purpose - Virtual Switch (VS) device on Vera to control an IFTTT device.

Method - Create a Virtual Switch, configure ALTUI/Webhooks/IFTTT as detailed in this thread

Result - The iFTTT device responds to every state change of the Virtual Switch as opposed to On for On and Off for Off. e.g If the device is turned off manually and the VS is still in the On Position, then by clicking the VS to Off this actually then turns the state of the device to On - states become out of sync.

Workaround - Configure IFTTT recipes for both On AND OFF states. Use PLEG to detect a trigger on the VS, use 2 actions in LUUP to send the native IFTTT maker and trigger keys for either ON or OFF. Use Vera IFTTT integration to detect when the IFTTT device state is changed locally and send that state back to Vera so devices are in sync. It works but it’s not elegant and needs a lot of configuration for one device.

So…could ALTUI do a better job ?

Thanks

David