Price sensor - jonasbkarlsson/ev_smart_charging GitHub Wiki
Definition of Generic price sensor
template:
- sensor:
- name: "my_price_sensor"
state: 123.45
attributes:
prices_today: >
[
{
"time": "2023-12-30 00:00:00+01:00",
"price": 120.00
},
{
"time": "2023-12-30 01:00:00+01:00",
"price": 121.00
},
...
{
"time": "2023-12-30 23:00:00+01:00",
"price": 143.00
}
]
prices_tomorrow: >
[
{
"time": "2023-12-31 00:00:00+01:00",
"price": 120.00
},
{
"time": "2023-12-31 01:00:00+01:00",
"price": 121.00
},
...
{
"time": "2023-12-31 23:00:00+01:00",
"price": 143.00
}
]
state
shall be the current price and be a float
object.
prices_today
shall be an array
of time/price dictionary
. If there is no valid prices today, it shall be an empty array []
or None
. An array with 12 or fewer elements is considered to be invalid. The elements in the array shall be sorted by time, with the earliest element first, and only include prices for today.
prices_tomorrow
shall be an array
of time/price dictionary
. If there is no valid prices tomorrow, it shall be an empty array []
or None
. An array with 12 or fewer elements is considered to be invalid. The elements in the array shall be sorted by time, with the earliest element first, and only include prices for tomorrow.
The last element in the prices_today
array shall have a time that is earlier than the time of the first element in the prices_tomorrow
array.
The time
element in the time/price dictionary
shall be a str
object using the ISO 8601 format or a datetime
object, and shall represent the local time and include time zone information.
The price
element in the time/price dictionary
shall be a float
object.
NOTE: For a template sensor, it seems not possible to create datetime
objects for the time
element. For a price sensor provided by an integration, it is recommended to use a datetime
objects for the time
element.
Also, it is highly recommented to set the configuration variables unique_id
, unit_of_measurement
, availability
, see this example.