SmartMeterP1 aggregate data

Begonnen von @lex99, 11 Februar 2022, 19:54:35

Vorheriges Thema - Nächstes Thema

@lex99

Hi,

I successfully connected my smart meter via another Pi to my FHEM Pi.

I get the readings every second, and this is filling the logs.

I want to reduce the logs frequency, so I decided to duplicate the events via notify commands.

As an example, this is what I have done for ElectricityPowerDelivered:

I created a Dummy: CompteurORES_Delivered_Dummy

I created a notify:CompteurORES_Delivered_notify
CompteurORES:ElectricityPowerDelivered.* {my $mydata=ReadingsVal("CompteurORES_Delivered_notify","triggeredByEvent",0);;fhem("trigger CompteurORES_Delivered_Dummy $mydata");;}

I created a FileLog: FileLog_CompteurORES_Delivered
./log/CompteurORES_Delivered-%Y-%m.log CompteurORES_Delivered_Dummy

It works well, I get the values in the log.

But my notify readings contain this:
triggeredByEvent   ElectricityPowerDelivered: 0.718834714600045

So the event-aggregate does not work.

How can I get rid of the ElectricityPowerDelivered in the readings ?

Or I am doing it the wrong way ?

Thanks !

Beta-User

According to my experience, transfering values from one device to another makes things more complicated in the end, especially in case you are just doing that wrt. to reduce logging.

I'd recommend to have a look at the so-called readingfn-attributes, especially "event-on-change-reading" (also with hysteresis) and "event-aggregator".

For more detailed help, having a list of your original device might help and also some excerpts from the event-monitor (you may limit the shown events by setting appropriate regex in filter).
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

@lex99

Thanks for your answer.

A bit more background: I would like to be able to command appliances depending on my current consumption and solar production of power.  Therefore, I am trying to create an average per minute or per 5 minutes of the power used in my home.  Further, the logs are filling up very fast for nothing (the power consumed reading ("ElectricityPowerDelivered") is producing 86400 lines in the log every day), so I was thinking to also reduce the logs; finally, I'd like to make graphs, and those are too slow with so many points to plot.

My electricity meter produces output every second, that is being input into FHEM.  Only modified values are logged by FHEM, example of my meter's log in FHEM:
2022-02-03_11:25:34 CompteurORES ElectricityPowerDelivered: 0.896 kW
2022-02-03_11:25:35 CompteurORES TelegramTime: 2022-02-03 11:25:35
2022-02-03_11:25:35 CompteurORES ElectricityDeliveredLowTariff: 212.821 kWh
2022-02-03_11:25:35 CompteurORES ElectricityPowerDelivered: 0.900 kW
2022-02-03_11:25:36 CompteurORES TelegramTime: 2022-02-03 11:25:36
2022-02-03_11:25:37 CompteurORES TelegramTime: 2022-02-03 11:25:37
2022-02-03_11:25:37 CompteurORES ElectricityPowerDelivered: 0.897 kW
2022-02-03_11:25:38 CompteurORES TelegramTime: 2022-02-03 11:25:38
2022-02-03_11:25:38 CompteurORES ElectricityPowerDelivered: 0.884 kW
2022-02-03_11:25:39 CompteurORES TelegramTime: 2022-02-03 11:25:39
2022-02-03_11:25:39 CompteurORES ElectricityDeliveredLowTariff: 212.822 kWh
2022-02-03_11:25:39 CompteurORES ElectricityPowerDelivered: 0.900 kW


This is the list of counters that can be updated by my smart meter:
ElectricityDeliveredLowTariff
ElectricityDeliveredNormalTariff
ElectricityPowerDelivered
ElectricityPowerProduced
ElectricityProducedLowTariff
ElectricityProducedNormalTariff
ElectricityThreshold
SwitchPositionElectricity
TariffIndicatorElectricity
TelegramTime
state


I have successfully used event-aggregator on my smart meter device in FHEM, on the reading "ElectricityPowerDelivered" to have only 1 logging per 10 seconds, but then I cannot use another event-aggregator on the same device to also reduce the logging of "ElectricityPowerProduced" (which is updated when I send power to the grid).

In the commandref, it is indicated to use a notify to multiply a device reading when we are hit by the limitation of only 1 event-aggregator possible per device.  This is what I was trying to do as described in my first post, and it works almost OK, except that I have my reading coming to:
triggeredByEvent   ElectricityPowerDelivered: 0.718834714600045

This is already a 10-seconds average (done by event-aggregator in the smart meter device, as a test).  And from this reading, event-aggregator won't work because of the "ElectricityPowerDelivered" text.  So if I can get rid of this text, and just keep the value in the field then it should work. 

Thanks !

@lex99

Ok, I solved the problem by changing my notify to:
CompteurORES:ElectricityPowerDelivered:.* {my $mydata=ReadingsVal("CompteurORES_Delivered_notify","triggeredByEvent",0);;fhem("setreading CompteurORES_Delivered_Dummy test $mydata")}

This way, the Dummy has a reading ("test") and I can do event-aggregate on it.

Thanks !

Beta-User

This still seems somehow strange to me.

I'd prefer keeping all data in the original device (and only logging the relevant ones in a pure numeric notation) and throttling by usage of event-aggregator and event-on- thresholds and exclude the timestamp-events at all.

Then: if at all doing it the "notify-way", in notify you may directly use $EVTPART1 (etc.) to just pick the numbers.
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files