- Platform information:
- Hardware: Rpi 3b+
- OS: openhabian (updated everything on 9 April 2025)
- Java Runtime Environment: openhabian default (I believe it is java 17)
- openHAB version: 4.3.4
I have this DSL script on OH3 and it runs normal to track if the sun is above horizon using astro binding and these run well:
rule "Outdoor Lights On - Sunset - 15 minutes"
when
Channel 'astro:sun:minus15:set#event' triggered START
then
logWarn("Sequences", "Astro sun minus15 set triggered, sequence now running")
OutdoorLight.sendCommand(ON)
Sunshine.sendCommand(OFF)
end
rule "Outdoor Lights Off - Sunrise - 10 minutes"
when
Channel 'astro:sun:plus10:rise#event' triggered START
then
logWarn("Sequences", "Astro sun plus15 rise triggered, sequence is now running")
OutdoorLight.sendCommand(OFF)
Sunshine.sendCommand(ON)
end
But I cannot transform this in blockly on OH 4
with this code generated (I run 2 blockly rules when triggered, one is disabled by commenting everything):
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Local_Sunrise_End_Time
timeOnly: false
offset: 600
type: timer.DateTimeTrigger
- id: "2"
configuration:
itemName: Local_Sunset_Start_Time
timeOnly: false
offset: -900
type: timer.DateTimeTrigger
conditions: []
actions:
- inputs: {}
id: "3"
configuration:
blockSource: '<xml xmlns="https://developers.google.com/blockly/xml"><block
type="oh_log" id="DFe1i$xU~Jw2d6P?6@PW" x="30" y="-43"><field
name="severity">info</field><value name="message"><shadow type="text"
id="Ih-rL:)ftP}anmLZeUGz"><field name="TEXT">abc</field></shadow><block
type="text_join" id="jB[pscyG]a/tHzXZ0_vd"><mutation
items="2"></mutation><value name="ADD0"><block type="text"
id="m/gPeZm8m{]Jyj{_,-n%"><field name="TEXT">Sunrise/set trigger is:
</field></block></value><value name="ADD1"><block type="oh_context_info"
id="!{JF9sSR5KkD.WL6I/$4"><mutation asType="null"
contextInfo="itemName"></mutation><field
name="contextInfo">itemName</field></block></value></block></value><next><block
type="controls_if" id=")Fo$y?gUw8uf[@+qa4Vu"><mutation
elseif="1"></mutation><value name="IF0"><block type="logic_compare"
id="TvRB2%Noz)2_E+~(N{7,"><field name="OP">EQ</field><value
name="A"><block type="oh_context_info"
id="g(f2?q7-5S{wv^[AliV`"><mutation asType="null"
contextInfo="itemName"></mutation><field
name="contextInfo">itemName</field></block></value><value
name="B"><block type="text_join" id="WG[ka~2dtO7.[$yO`Fa7"><mutation
items="1"></mutation><value name="ADD0"><block
type="oh_getitem_attribute" id="9:W`5dQmA/M0Du1P/GcH"><mutation
attributeName="Name"></mutation><field
name="attributeName">Name</field><value name="item"><shadow
type="oh_getitem" id="ciLRUdmrUp$KG$InstuV"><value
name="itemName"><shadow type="oh_item"
id="GV|nHOCExt_z^Hn;9N2T"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow></value></shadow><block
type="oh_getitem" id="6-ro2?`k[_r$7_J12u}Y"><value
name="itemName"><shadow type="oh_item"
id="GV|nHOCExt_z^Hn;9N2T"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id=":;0?wrX!mF)qfL,^tGsR"><mutation itemName="Local_Sunrise_End_Time"
itemLabel="Local Sunrise End Time"></mutation><field
name="itemName">Local_Sunrise_End_Time</field></block></value></block></value></block></value></block></value></block></value><statement
name="DO0"><block type="oh_log" id="j_i*uJK_Jtc^1Q|84m;v"><field
name="severity">info</field><value name="message"><shadow type="text"
id="Ih-rL:)ftP}anmLZeUGz"><field name="TEXT">abc</field></shadow><block
type="text_join" id="F)OY7j]/V.U-?KO}SLq!"><mutation
items="2"></mutation><value name="ADD0"><block type="text"
id="y7blR_|bx.:5-tO=8Zz)"><field name="TEXT">Sunrise/set trigger is:
</field></block></value><value name="ADD1"><block type="oh_context_info"
id="[#=w+OV3(003p%bIp4}]"><mutation asType="null"
contextInfo="itemName"></mutation><field
name="contextInfo">itemName</field></block></value></block></value><next><block
type="oh_event" id="vkKj^xqFhvct|8Z:=i0{"><field
name="eventType">sendCommand</field><value name="value"><shadow
type="text" id="VeB,?!u~ejJ?i[$Sk[i2"><field
name="TEXT">value</field></shadow><block type="text"
id="_;`BVoOKf_)_:L!DdCV="><field
name="TEXT">ON</field></block></value><value name="itemName"><shadow
type="oh_item" id="Yc)3ZO@/NZB|?-z[Wjf?"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="q7VHP$/6]6[nUy?u8/iz"><mutation itemName="Sunshine_Full"
itemLabel="Full Sunshine"></mutation><field
name="itemName">Sunshine_Full</field></block></value></block></next></block></statement><value
name="IF1"><block type="logic_compare" id="E_LZFCt29}5ph4)`UmcY"><field
name="OP">EQ</field><value name="A"><block type="oh_context_info"
id="oaGhggFJ#s)_}0JLfrL`"><mutation asType="null"
contextInfo="itemName"></mutation><field
name="contextInfo">itemName</field></block></value><value
name="B"><block type="text_join" id="KjjJAr=?WiLG?X}1{UXW"><mutation
items="1"></mutation><value name="ADD0"><block
type="oh_getitem_attribute" id="v{/QTO}8Q!L@XH`9_A3g"><mutation
attributeName="Name"></mutation><field
name="attributeName">Name</field><value name="item"><shadow
type="oh_getitem" id="ciLRUdmrUp$KG$InstuV"><value
name="itemName"><shadow type="oh_item"
id="GV|nHOCExt_z^Hn;9N2T"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow></value></shadow><block
type="oh_getitem" id="C;7gKiIUtN8^`~@}3YdX"><value
name="itemName"><shadow type="oh_item"
id="GV|nHOCExt_z^Hn;9N2T"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="1=4Qj?ua,DJx6;s/$[TI"><mutation itemName="Local_Sunset_Start_Time"
itemLabel="Local Sunset Start Time"></mutation><field
name="itemName">Local_Sunset_Start_Time</field></block></value></block></value></block></value></block></value></block></value><statement
name="DO1"><block type="oh_log" id="zZ#X=zgy:HOIc^1R4]!W"><field
name="severity">info</field><value name="message"><shadow type="text"
id="Ih-rL:)ftP}anmLZeUGz"><field name="TEXT">abc</field></shadow><block
type="text_join" id=";j0g,gx57BD(fm2xp1=e"><mutation
items="2"></mutation><value name="ADD0"><block type="text"
id="g$Km;^233G/~bAmeQ7uV"><field name="TEXT">Sunrise/set trigger is:
</field></block></value><value name="ADD1"><block type="oh_context_info"
id="JYDW|16c?h)QjHK$jq=Q"><mutation asType="null"
contextInfo="itemName"></mutation><field
name="contextInfo">itemName</field></block></value></block></value><next><block
type="oh_event" id="{qM${,Y?QCJzv`Iw6R2X"><field
name="eventType">sendCommand</field><value name="value"><shadow
type="text" id="VeB,?!u~ejJ?i[$Sk[i2"><field
name="TEXT">value</field></shadow><block type="text"
id="3|xi`y}Fw8,zGC{E9XGr"><field
name="TEXT">OFF</field></block></value><value name="itemName"><shadow
type="oh_item" id="Yc)3ZO@/NZB|?-z[Wjf?"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="x9LeH@G9r3k~CYwuD?[8"><mutation itemName="Sunshine_Full"
itemLabel="Full Sunshine"></mutation><field
name="itemName">Sunshine_Full</field></block></value></block></next></block></statement></block></next></block></xml>'
type: application/javascript
script: >
console.info(('Sunrise/set trigger is: ' + String(event.itemName)));
if (event.itemName ==
String(items.getItem('Local_Sunrise_End_Time').name)) {
console.info(('Sunrise/set trigger is: ' + String(event.itemName)));
items.getItem('Sunshine_Full').sendCommand('ON');
} else if (event.itemName ==
String(items.getItem('Local_Sunset_Start_Time').name)) {
console.info(('Sunrise/set trigger is: ' + String(event.itemName)));
items.getItem('Sunshine_Full').sendCommand('OFF');
}
type: script.ScriptAction
Can you guys direct me which part is wrong on my triggers/blockly?
TIA