Sorry, but I cannot answer your question, as I did not create that chart.
The consumption for yesterday is the last value stored in daily consumption You might need an offset in the chart to have it shown at the correct day. Other option would be to use an aggregation on top of the actual consumption.
Thank you, I will try and see if i can make your suggestion possible. The offset might be closer to what i might be able to do.
Hello,
I’m new to Openhab and got stuck. It should be something simple, but I can’t see where.
Log entry:
WARN org.openhab.core.automation.module.script.internal.defaultscope.ScriptBusEventImpl State 'PersistedState (State=1 kWh)' cannot be parsed for item 'RekuperatoriausKwhDaily'.
My points, they all configured the same
configuration:
persistenceService: rrd4j
energyUsageMonthly: RekuperatoriusKwhMonthly
energyCounter: Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number
energyUsageYearly: RekuperatoriusKwhYearly
energyUsageDaily: RekuperatoriausKwhDaily
energyUsageWeekly: RekuperatoriusKwhWeekly
triggers:
- id: "1"
configuration:
cronExpression: 1 0 0 * * ? *
type: timer.GenericCronTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
type="oh_event" id="DcoZNq7swfEZoj)0Ua]X" x="-820" y="-416"><field
name="eventType">postUpdate</field><value name="value"><shadow
type="text" id="#(yQc8CV:OKPW@[kDmLq"><field
name="TEXT">value</field></shadow><block type="oh_get_persistvalue"
id="QcdG@s#+KDDo52O!ai.+"><field
name="methodName">deltaSince</field><value name="itemName"><shadow
type="oh_item" id="Py}?{~?.icb-QZU-}e|%"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="{c|-MK@dbovJXw#OdoU%"><mutation
itemName="Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number"
itemLabel="Energie Counter"></mutation><field
name="itemName">Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number</field></block></value><value
name="persistenceName"><shadow type="oh_persistence_dropdown"
id="a|^dX_MtavSf1=2cxeGW"><field
name="persistence">default</field></shadow><block
type="oh_persistence_dropdown" id="u.6YT}kCv9:!jJLX)Ha|"><field
name="persistence">rrd4j</field></block></value><value
name="dayInfoSince"><block type="oh_zdt_plusminus"
id="[bDW~ua-t]1?8nutF9y!"><field name="plusminus">minus</field><field
name="period">Days</field><value name="offset"><shadow
type="math_number" id="{sVjuwBlf6dS!(gW*BYk"><field
name="NUM">0</field></shadow><block type="math_number"
id="WSiMw);T_W7KBh@4-u_L"><field
name="NUM">1</field></block></value></block></value></block></value><value
name="itemName"><shadow type="oh_item"
id="NPb)7;I@d$=vPq^*MJ)`"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="a8-G;5w)iG|(X+LUPFbs"><mutation itemName="RekuperatoriausKwhDaily"
itemLabel="Daily energy consumption"></mutation><field
name="itemName">RekuperatoriausKwhDaily</field></block></value><next><block
type="controls_if" id="0?4$NID6H0C9A#:}wuQ!"><value name="IF0"><block
type="logic_compare" id="U6pYz7%x*I#a`^Y!pGY~"><field
name="OP">EQ</field><value name="A"><block type="oh_get_zdt_part"
id="RR$AD9u6D!yHL3_n!WXk"><field
name="temporalPart">getDayOfWeek</field><value name="zdt"><block
type="oh_zdt_now"
id="nYo=K+nRS]V%g#,Pi;t/"></block></value></block></value><value
name="B"><block type="math_number" id="9%MBAcAkS:LmTC52RXu*"><field
name="NUM">1</field></block></value></block></value><statement
name="DO0"><block type="oh_event" id="{8[5EibFv*n^xlsfU_9r"><field
name="eventType">postUpdate</field><value name="value"><shadow
type="text" id="#(yQc8CV:OKPW@[kDmLq"><field
name="TEXT">value</field></shadow><block type="oh_get_persistvalue"
id="%EWS?a0ed.^2W%u0r/4T"><field
name="methodName">deltaSince</field><value name="itemName"><shadow
type="oh_item" id="4~Z=Bm{5152mLS;7$5k}"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="|D|At2K+fPXe#|m]z}MD"><mutation
itemName="Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number"
itemLabel="Energie Gesamt"></mutation><field
name="itemName">Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number</field></block></value><value
name="persistenceName"><shadow type="oh_persistence_dropdown"
id="a|^dX_MtavSf1=2cxeGW"><field
name="persistence">default</field></shadow><block
type="oh_persistence_dropdown" id="O_c{pjiLi0O6(c+/5ug5"><field
name="persistence">rrd4j</field></block></value><value
name="dayInfoSince"><block type="oh_zdt_plusminus"
id="y[1(nPz]4`Nk7Kq#pVMS"><field name="plusminus">minus</field><field
name="period">Weeks</field><value name="offset"><shadow
type="math_number" id="%ENY;4,LF9~rYdncN*J."><field
name="NUM">0</field></shadow><block type="math_number"
id="n};3a{3CvDCE)8$V]V9%"><field
name="NUM">1</field></block></value></block></value></block></value><value
name="itemName"><shadow type="oh_item"
id="#fQEeLvX$:+Ok0s-_ndA"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="4TyCQX|zx,QZlhsj[R4d"><mutation itemName="RekuperatoriusKwhWeekly"
itemLabel="Weekly energy consumption"></mutation><field
name="itemName">RekuperatoriusKwhWeekly</field></block></value></block></statement><next><block
type="controls_if" id="|NWnM*J!|AH9]Zfa[w-m"><value name="IF0"><block
type="logic_compare" id="[E}0z@95rr_-(^9a##Iq"><field
name="OP">EQ</field><value name="A"><block type="oh_get_zdt_part"
id="(hY?hpqJyp,-~lbvVgB]"><field
name="temporalPart">getDayOfMonth</field><value name="zdt"><block
type="oh_zdt_now"
id="(Dm;y)NZo`dU-VwwNI,q"></block></value></block></value><value
name="B"><block type="math_number" id="i{%ezg~{d;[v`o^#g[L,"><field
name="NUM">1</field></block></value></block></value><statement
name="DO0"><block type="oh_event" id=",%4=aUR`Dp;lZk[vS=iI"><field
name="eventType">postUpdate</field><value name="value"><shadow
type="text" id="#(yQc8CV:OKPW@[kDmLq"><field
name="TEXT">value</field></shadow><block type="oh_get_persistvalue"
id="*}wUT?2YIi{%UWLFF)R["><field
name="methodName">deltaSince</field><value name="itemName"><shadow
type="oh_item" id="E16,H4)4DqzApG}4|Mrm"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="1u;KZKQ;4ytz0hKJT;/f"><mutation
itemName="Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number"
itemLabel="Energie Gesamt"></mutation><field
name="itemName">Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number</field></block></value><value
name="persistenceName"><shadow type="oh_persistence_dropdown"
id="a|^dX_MtavSf1=2cxeGW"><field
name="persistence">default</field></shadow><block
type="oh_persistence_dropdown" id="`w~opwkei^7CIB3FrO+."><field
name="persistence">rrd4j</field></block></value><value
name="dayInfoSince"><block type="oh_zdt_plusminus"
id="Z?~MSD!-em3!8FSpdz8c"><field name="plusminus">minus</field><field
name="period">Months</field><value name="offset"><shadow
type="math_number" id="#+a!N7#(|H6,-X8@ROJU"><field
name="NUM">0</field></shadow><block type="math_number"
id=")^WuCM:FMVt1,K*X5STB"><field
name="NUM">1</field></block></value></block></value></block></value><value
name="itemName"><shadow type="oh_item"
id="u9c,ktf{y}x6}w%8#jj~"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="Sc9a}rvsYblGZ4/n@Rs]"><mutation itemName="RekuperatoriusKwhMonthly"
itemLabel="Monthly energy consumption"></mutation><field
name="itemName">RekuperatoriusKwhMonthly</field></block></value></block></statement><next><block
type="controls_if" id="Z|(jQNM~N;sjEs_9,OD,"><value name="IF0"><block
type="logic_compare" id="~BC$sP`2wv49=P@wbIQl"><field
name="OP">EQ</field><value name="A"><block type="oh_get_zdt_part"
id="%X4Q/;r!xG,lPkC3i,~E"><field
name="temporalPart">getDayOfYear</field><value name="zdt"><block
type="oh_zdt_now"
id="1/mF/jsRwX7L}-V/eu8#"></block></value></block></value><value
name="B"><block type="math_number" id="C8-sV|{33~aWV%c8.]5|"><field
name="NUM">1</field></block></value></block></value><statement
name="DO0"><block type="oh_event" id="ThuO;#wF9bwNr`GCc#zC"><field
name="eventType">postUpdate</field><value name="value"><shadow
type="text" id="#(yQc8CV:OKPW@[kDmLq"><field
name="TEXT">value</field></shadow><block type="oh_get_persistvalue"
id="e!g~$Qww)$==?dC|Ph?."><field
name="methodName">deltaSince</field><value name="itemName"><shadow
type="oh_item" id="E16,H4)4DqzApG}4|Mrm"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="#($cP7M_#{wMbxt.#k[b"><mutation
itemName="Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number"
itemLabel="Energie Gesamt"></mutation><field
name="itemName">Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number</field></block></value><value
name="persistenceName"><shadow type="oh_persistence_dropdown"
id="a|^dX_MtavSf1=2cxeGW"><field
name="persistence">default</field></shadow><block
type="oh_persistence_dropdown" id="3A$FKU5,%6(lF$U]q[Sr"><field
name="persistence">rrd4j</field></block></value><value
name="dayInfoSince"><block type="oh_zdt_plusminus"
id="Sy2=fJPU]:hwbCwD+B|Y"><field name="plusminus">minus</field><field
name="period">Years</field><value name="offset"><shadow
type="math_number" id="#+a!N7#(|H6,-X8@ROJU"><field
name="NUM">0</field></shadow><block type="math_number"
id="?n62/(a806h70QpkWW+2"><field
name="NUM">1</field></block></value></block></value></block></value><value
name="itemName"><shadow type="oh_item"
id="u9c,ktf{y}x6}w%8#jj~"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="?(##OvabvK76gTfk7(Q2"><mutation itemName="RekuperatoriusKwhYearly"
itemLabel="Yearly energy consumption"></mutation><field
name="itemName">RekuperatoriusKwhYearly</field></block></value></block></statement></block></next></block></next></block></next></block></xml>
type: application/javascript
script: >
items.getItem('RekuperatoriausKwhDaily').postUpdate((items.getItem('Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number').persistence.deltaSince(time.ZonedDateTime.now().minusDays(1),
'rrd4j')));
if (((time.ZonedDateTime.now()).dayOfWeek().value()) == 1) {
items.getItem('RekuperatoriusKwhWeekly').postUpdate((items.getItem('Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number').persistence.deltaSince(time.ZonedDateTime.now().minusWeeks(1), 'rrd4j')));
}
if (((time.ZonedDateTime.now()).dayOfMonth()) == 1) {
items.getItem('RekuperatoriusKwhMonthly').postUpdate((items.getItem('Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number').persistence.deltaSince(time.ZonedDateTime.now().minusMonths(1), 'rrd4j')));
}
if (((time.ZonedDateTime.now()).dayOfYear()) == 1) {
items.getItem('RekuperatoriusKwhYearly').postUpdate((items.getItem('Modbus_Data__EatonEasyE4_PLC__Rekupeatoriaus_viso_kwh_Value_as_Number').persistence.deltaSince(time.ZonedDateTime.now().minusYears(1), 'rrd4j')));
}
type: script.ScriptAction```
You item state is NULL, therefore it has no persisted state.
Not sure how that works, but how I could update it to something non-NULL? I guess I could link with the same energy counter to get the value updated, then unlink it, but this does not sound like a good way of doing.
I was execting a method items.getItem('RekuperatoriausKwhDaily').postUpdate(
will do the trick
Correct, this updates the item.
Not sure why it does not for you.
Tried to restart the whole openhabian - did not help.
Tried adding items.getItem('RekuperatoriausKwhDaily').postUpdate(0);
to see whether value changes. And it does
It updated the value of the item, now its 0kWh
But there’s the same log message
WARN org.openhab.core.automation.module.script.internal.defaultscope.ScriptBusEventImpl State 'PersistedState (State=1 kWh)' cannot be parsed for item 'RekuperatoriausKwhDaily'.
Is it something to do with units? But both items are set identical, with identical units set
label: Rekuperatoriaus Viso kWh
type: Number:Energy
category: energy
groupNames:
- Rekuperatorius
tags:
- Point
- Energy
label: "Rekuperatoriaus Dienos kWh "
type: Number:Energy
category: energy
groupNames:
- Rekuperatorius
tags:
- Point
- Energy
You tried running the rule manually ?
When did you create the counter Item.
Please check if there are persisted states for the counter, otherwise historical states will not work.
Yes, I did. Every time it runs, gives the same warning message.
Counter item was create a week or so ago. Consumption is not that great now, but there’s still a 1kWh difference in past 24h, so this part PersistedState (State=1 kWh)
in warning message seems to be correct.
I need to check this evening, your rule looks a bit different than mine…
Ok, I found a way how to view the script in Blocky. Was a bit nervous about how you guys on previous discussion with sipvoip got that open.
Once opened I got this message:
After saving rule started to work!
On left, the there’s original script, came just after I set up the rule out of installed template.
On right, updated. It now specify format (can you call it format?) as number
Mystery got solved.
Exactly wat I was going to check
Glad you solved it yourself
Thanks for support
Hi @hmerk !
I made a small change to set the week, month and year variables to “0” (zero) at the beginning of the code.
This way, we will not have NULL until these variables are set by the IF block.
In some countries (languages) first Day Of Week maybe the sunday (7) or monday (1) as far as I know.
Thanks for this template.
@hmerk
I like idea of your add-on. Tested on one item and it works well. However I would like to adapt that rule for about 15 items, so working with text and not hundreds of clicks would be optimal.
Could you please make it clear if used id`s
id="Py}?{~?.icb-QZU-}e|%"
id="WSiMw);T_W7KBh@4-u_L"
id="a8-G;5w)iG|(X+LUPFbs"
...
are really important for your rule? Is there some specific knowledge needed to create it from notepad? I guess all should be unique but any specific length? Are they somewhere else used?
This is just from the blockly part of the rule template. You can use the script part from the bottom of the rule, which is the plain javascipt code.