Trying to log current energy usage

Posted on
Sun Aug 22, 2021 1:40 pm
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

Trying to log current energy usage

I want to create some automation in Indigo based upon the energy usage of a device.
To prepare this I need to know what kind of energy is used at certain times, so I tried to start with a simple trigger that logs the current energy usage.
Should be straight forward? Yes. Is it? Well...

Added a new trigger for the device for the Current Power (Watts) on any change.
Action is Write to Log and then the journey begins...

I need to enter %%d:DEVICEID:STATEKEY%% as is mentioned in the explanation. But it is a bit hard to read as the text is dark grey on a light grey background. And the first % is at the end of the preceding line.
Next I need to determine the DEVICEID. That's easy. And the STATEKEY.
But where do I get that? It is not "Current Power (Watts) as shown in the Trigger tab.

It should be "...the state identifier as found in the documentation for built-in devices...".
So let's dive into the Indigo Object Model Reference for Devices. There it lists the Device Base Class with the Base Class Properties. And one of the properties is "energyCurLevel".
However entering %%d:60534787:energyCurLevel%% is not accepted. :?

The only other info to be found on this page is that you can get an indigo.Dict() of the device states. So I opened a scripting shell and entered:

Code: Select all
>>> dev = indigo.devices["Wasdroger"]
>>> for state in dev.states:
...   print(state)
...
accumEnergyTimeDelta
accumEnergyTimeDelta.ui
accumEnergyTotal
accumEnergyTotal.ui
curEnergyLevel
onOffState
>>>

Aha! This looks like the info I might be looking for.
Entered %%d:60534787: curEnergyLevel%% in the Trigger Action and now it is accepted.

Searched for curEnegeryLevel on the IndigoDomo site to see if I might have missed something, but there is no mention at all of this.

I think there is some room for improvement here. It shouldn't be that difficult to create a trigger like this.
It took a lot of energy on my side to get this to work. :wink:

Posted on
Mon Aug 23, 2021 5:25 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Trying to log current energy usage

Can you clarify your suggestion a little bit?

Is your suggestion that it should be easier to include a reference to a device state or variable value in the Write to Log action? Or is it that the object model reference documentation could be written more clearly? Or both?

You might take a look at my Multitool plugin. One of the tools is a Substitution Generator which will create a complete substitution string for any device or variable. You can use the tool to create the needed substitution string before creating the log action.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Aug 23, 2021 5:38 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

Re: Trying to log current energy usage

Is your suggestion that it should be easier to include a reference to a device state or variable value in the Write to Log action? Or is it that the object model reference documentation could be written more clearly? Or both?

I would say both. I know that it is a difficult job to keep documentation up to spec (and a big thumbs up to Matt and Jay for writing it all up) , but that should be the first step. Having a means to easily get the desired info out of Indigo would also be a big help.
Suggestion: One can right click on a device and get the DeviceID and dependencies and other details. Maybe it could be possible to add a menu option that lists all the state keys that are available.

Posted on
Mon Aug 23, 2021 5:45 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

Re: Trying to log current energy usage

Installed your MultiTool and that looks good. It gave me the info I needed. And more.

Posted on
Mon Aug 23, 2021 5:52 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Trying to log current energy usage

macpro wrote:
Installed your MultiTool and that looks good. It gave me the info I needed. And more.


Great. The documentation is hosted on GitHub and the main tools are listed on the Menu Items page. Please let me know if you see anything that could be improved.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Aug 23, 2021 9:47 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trying to log current energy usage

macpro wrote:
Suggestion: One can right click on a device and get the DeviceID and dependencies and other details. Maybe it could be possible to add a menu option that lists all the state keys that are available.


We have a popup for custom states, but adding one for the built-in properties like that would be very useful. I've added a feature request.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 20, 2021 7:13 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

Re: Trying to log current energy usage

And it's available in Indigo 2021.2. Thanks!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests