openhab / openhab-core

Core framework of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
925 stars 428 forks source link

Time series support for Group items #3869

Open jlaur opened 1 year ago

jlaur commented 1 year ago

See https://github.com/openhab/openhab-core/pull/3597#issuecomment-1764048531

Currently bindings can publish time series for channels. Transformation Profiles are supported as well.

I don't know if it would be possible to extend time series support to Group items as well, since they can also be persisted?

Example configuration:

Group:Number:SUM EnergiDataService_TotalPrice "Total [%.2f DKK]" <price>

Number EnergiDataService_SpotPrice "Spotpris [%.2f DKK]" <price> (EnergiDataService_TotalPrice) { channel="energidataservice:service:energidataservice:electricity#spot-price" [profile="transform:VAT"] }
Number EnergiDataService_NetTariff "Nettarif [%.2f DKK]" <price> (EnergiDataService_TotalPrice) { channel="energidataservice:service:energidataservice:electricity#net-tariff" [profile="transform:VAT"] }
Number EnergiDataService_SystemTariff "Systemtarif [%.2f DKK]" <price> (EnergiDataService_TotalPrice) { channel="energidataservice:service:energidataservice:electricity#system-tariff" [profile="transform:VAT"] }
Number EnergiDataService_ElectricityTax "Elafgift [%.2f DKK]" <price> (EnergiDataService_TotalPrice) { channel="energidataservice:service:energidataservice:electricity#electricity-tax" [profile="transform:VAT"] }
Number EnergiDataService_TransmissionNetTariff "Transmissionsnettarif [%.2f DKK]" <price> (EnergiDataService_TotalPrice) { channel="energidataservice:service:energidataservice:electricity#transmission-net-tariff" [profile="transform:VAT"] }

Here EnergiDataService_TotalPrice represents the total price. Unfortunately time series are not supported, so the future total price cannot be persisted.

Historical values can currently be shown in a sitemap chart like this:

Text item=EnergiDataService_TotalPrice {
    Chart item=EnergiDataService_TotalPrice forceasitem=true refresh=60000 period=D
}
J-N-K commented 1 year ago

But isn't the group correctly updated when the member states are restored?

jlaur commented 1 year ago

But isn't the group correctly updated when the member states are restored?

Indeed it is. I'm wondering if it would also be possible to have the group receive time series and create a new time series, similar to what TimeSeriesProfile does for profiles? I realize it would be more complex, since it would have to "replay" received time series for all related children. E.g.:

Group:Number:SUM SumGroup
Number Item1 (SumGroup) { channel="acme:acme:channel1 }
Number Item2 (SumGroup) { channel="acme:acme:channel2 }

Events:

As a result, the following time series would be produced and published for item SumGroup:

I guess this would have been easier achievable with a closer state integration, i.e. https://github.com/openhab/openhab-core/pull/3597#issuecomment-1787573748 - if the magic happens only when reaching the event bus?

J-N-K commented 10 months ago

I still fail to see what the use-case would be? Calculating future states is extremely difficult, because it needs to be re-done every time a single value for any item in the group has changed.

jlaur commented 10 months ago

I still fail to see what the use-case would be?

It's in the description, and some reasoning for not providing a "total price" channel from the binding is here: https://www.openhab.org/addons/bindings/energidataservice/#channel-group-electricity

At least, at the time it seemed elegant to use the Group SUM aggregate function for this because it already existed and it removed a lot of complexity from the binding itself.

Now, it would be cool to be able to create a chart of the future total price. With #3896 it would be possible to create a rule for calculating this instead of using a Group, but it still feels like it would be more elegant simply having the Group do the work without any rules needed.

Calculating future states is extremely difficult, because it needs to be re-done every time a single value for any item in the group has changed.

Yeah, I came to the same realization when I created the example above in my previous post. :sweat:

openhab-bot commented 6 months ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/bringing-electricity-information-from-eloverblik-dk-and-energidataservice-dk-into-openhab/143470/101

lolodomo commented 4 months ago

@jlaur : is it something to close now ?

jlaur commented 4 months ago

is it something to close now ?

I still think it would be a nice feature to have group aggregations support time series. I might give it a shot at some point.

openhab-bot commented 1 month ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/entsoe-binding-4-0-0-5-0-0/149699/60