Attribute "Price" for power in SA or DH


#1

Not sure if any device handler uses this, and/or if it is available in WebCoRE.
If a custom, Device Handler would have a attribute containing the price for power.
This could be usefull for controlling things using power.
Is this value available anywhere?
@ady624 you know for sure, but there might be answers in the forum also :slight_smile:
@webCoRE_Minions

Reason for asking is that i am looking into fetching price pr kwh from a vendor dynamically.
:snowman_with_snow:


#2

Are you trying to deal with things like variable pricing for peak hours, holidays, etc or just a flat price per kWh? Is your power deregulated with separate companies and pricing for supplier and distributor?

Seems like a useful thing to track in a global variable if you can set up a piston to get the value from a web site or API. Maybe someone has seen a DTH that is capable of this, but that seems like a stretch if you have numerous kinds of power metering devices.

I’m not sure what other questions to ask for you in Norway, US perspective here :wink:


#3

Thank you.
I am looking into a vendor that gives me variable prices throug the day.
So if a smart app could sync the price pr kwh into a device that webcore could use.
I could alarm on high prices, and even turn things on/off regarding to the pricetag.


#4

Was just browsing and, for whatever reason, stumbled into this…

I think you have a few possible pistons that need to be developed to achieve this:

  1. You first need to capture the price/kwh in some sort of variable so you have a basis for your calculation. Is the price variability on a random schedule or is it fixed? Do you have a pricing contract or is it arbitrary based on local supply/demand levels? These would be important questions to have answered to determine what variables you are going to need. Just price? Price and date/time? Duration? How often does pricing change?
  2. Do you have a feed you can gather the current price from? Is it something that can be accessed via an API or web service? If not - I fear this is all just an academic discussion. If you are having to constantly update the price manually - it defeats the point.
  3. Are you REALLY going to be able to reduce your consumption based on price fluctuations? Again, if you are just looking for alerts there may be simpler ways. If you want to maybe turn off some lights or adjust the temperature I can see the point.

The first 2 questions are critical. The 3rd question might be a bit more subjective.


#5

Pulling in @Cozdabuch who uses a piston to control air conditioning for off-peak savings.


#6

First Thanks a lot for looking into this.
Here in Norway we have a new system that gives us different price depending on the demand through the day.
Our meter reports in each hour
So let’s say, at 5 pm when people starts heating houses, preparing food and charge their car the price will be high, and mid-day/night the price will be low.
My new vendor gives me the real time price in a way that I can fetch through a API on their site.
https://developer.tibber.com/
If I then could fill that price into av virtual device from a Smart app i could use this flexible in WebCoRE was my thoughts.

:snowman:


#7

@bangali are the rates published? Or do the rates and times change at the power company’s discretion?

Mine is a handful of rates that vary by time of day and day of week. But the rates during those times don’t change.

Mine are as follows:

M-F
12:00-19:00 .24/KWh
19:01-23:59 .06/KWh
00:00-05:00 .04/KWh
05:00-11:59 .06/KWh

S-S & Holidays (on electric company website)
ALL TIMES .06/KWh

So I have hvac related stuff happen at certain times. Same with electric car charging based on lowest rates. But it checks holiday or weekend daily and sets an override variable that doesn’t run the scheduled tasks on those days, and if no override it runs stuff based on time period

If your rate changes at random my examples won’t help. If your rate is scheduled to change/rotate at certain times, it certainly will.


#8

Dynamic and powered by a bot.
Price in Norwegian currency of course :slight_smile:


#9

I really don’t beleive you need a SmartApp to get the price data. WebCoRE can make a web request and get the pricing data for you (assuming a standardized response like JSON or something parseable) which you can store in variables.

Here’s some pseudo-code for you to consider:

  • Create two global variables: $Current_Power_Price; $New_Power_Price
  • Create a “Power Savings” piston that will reduce your power consumption as you see fit.
  • Create a piston that retrieves the “new” price on a regular basis (every x minutes) and stores it in the $New_Power_Price global variable
  • If $Current_Power_Price < $New_Power_Price then execute “Power Savings” piston
  • Always set $Current_Power_Price to $New_Power_Price whenever your logic completes

See - no SmartApp. WebCoRE is all you need.


#10

Thx a bunch!!!
I still think that Tibber might want to exchange data in between their system and ST through a SA/DH
But this is all helpfull when i go into discusions with Tibber (power sales company) in a few days.
:snowman_with_snow:


#11

Are you planning on commercializing this effort? If so, then yes I would agree, a SA/DH is probably the way to go. I’m also not sure you could use WebCoRE for commercial purposes anyway. If for personal-use, I’m not sure they would care AND a SA/DH is going to be far more complex.


#12

I am just a customer of their power sales service, and I would love to se them integrate with Smartthings.
But I am a bit of a fan of WebCoRe :wink: so I would love to be able to use the “price” as an attribute in WebCoRE.
I doubt they will go for a solution purely based on WebCoRE, but I will discuss with them in a few days.
So my questions is more to be prepared when i will talk Smartthings with them.

:snowman:


#13

Wow.
Well if you can pull the rate into a local variable, have the piston run comparisons between rate and set 3-4 price brackets for your high energy draw items via pistons.

The idea:
If price is
(1-4) then set variable to A
(5-9) then set variable to B
(10-14) then set variable to C
(11-15) then set variable to D

When Variable changes, set global variable to same value
(I’m only suggesting keeping a local variable too Incase you want to use it further within the piston, if not just have all the ifs set global)

Take your HVAC piston for example
Obviously you can break it down by awake/sleep modes, outside temps, home vs away, triggers for coming or going, but for the sake of this I’m just being super simple.

If variable changes, then:
If variable = A, then set HVAC to 25 degrees
If variable = B, then set HVAC to 28 degrees
If variable = C, then turn off HVAC (unless outside temp is above 35 decrees)
If variable = D, turn off all non essential lights, HVAC off regardless of temp if nobody is home.


#14

I’m not sure you understand the implications of writing a SA/DH just to get data from an API. I also don’t think the power company / API provider will care what platform you are pulling their data into UNLESS you are doing it for commercial gain.

In any event, good luck!


#15

this would be fairly easy to do assuming you already know your rate code if the power companies provide an api to poll for the reading and rate data.


#16

So @jeffh0821 is this something I could do as a GET (Total) ? as long as i got the token?
Major ditance away from my line of work :wink:
Give me an router, firewall, switch and we will talk about it… hehe

{
viewer {
homes {
currentSubscription{
priceInfo{
current{
total
energy
tax
startsAt
}
}
}
}
}
}


#17

Based on that data after doing the GET request you would access the total value using an expression based on $response.*, like this:

$response.data.viewer.homes[0].currentSubscription.priceInfo.current.total

#18

Thx a bunch @ipaterson closing up to something here
Got a demo token to play with, and think i am near goal.
This in curl om my mac works:
curl
-H “Authorization: Bearer d1007ead2dc84a2b82f0de19451c5fb22112f7ae11d19bf2bedb224a003ff74a”
-H “Content-Type: application/json”
-X POST
-d ‘{ “query”: “{viewer {homes {currentSubscription {priceInfo {current {total energy tax startsAt }}}}}}” }’ https://api.tibber.com/v1-beta/gql

And tring to make a piston with the folowing as input.
Cant seme to save this as a variable, some syntax error.
The piston is NO share, Yeah i know, but this i a demo thingy :slight_smile:
This is the input i cant save:
Data : { “query”: “{viewer {homes {currentSubscription {priceInfo {current {total energy tax startsAt }}}}}}” }
Any idea?

Piston under.


#19

It looks like you will need a string variable named query with the value \{viewer \{homes \{currentSubscription \{priceInfo \{current \{total energy tax startsAt \}\}\}\}\}\} where the backslashes stop webCoRE from trying to pick out expressions. You can provide that query variable in the data for the request, then the token (including “Bearer”) in the authorization header input.

Also highly recommend censoring your post if that’s a permanent token.


#20

YOU DA MAN!!!
Works.
I am realy thankfull.
And yeah, I would never share anything with my own info.
I got a demo token from the vendor to test things, but anonymous piston kinda removed my url so i might have errors in that also.
Next up to get values into different variables.
Once again, thank you!!!
:snowman: