good morning, I have a problem with this rule. I have two routines: entry and exit. With the gptracker binding I would like it to activate the “entry” rule when I am close to home. I use the “distance” channel for the position and the “region” channel as the flag. The problem is that in the exit phase, I should time the rule to give you time to “exit” from region and distance, otherwise it reactivates “entry” for me. I attach the code, thanks for the suggestions.
I forgot… the radius is 10
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Tracker_Device_System_Distance
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "3"
configuration:
blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
type="oh_log" id="*Xrd#%3svH^4y6m.Ik#b" x="328" y="179"><field
name="severity">info</field><value name="message"><shadow type="text"
id="FQCl`15FD#D3gV]tNtSG"><field name="TEXT">abc</field></shadow><block
type="oh_getitem_state" id="iizx-/C=y!hbk==KxRq5"><value
name="itemName"><shadow type="oh_item"
id="[G.t%ieECVaH)vDM`o08"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id=";I(z?%hy?PBGYXHX*OlI"><mutation
itemName="Tracker_Device_Region_Trigger" itemLabel="Region
Trigger"></mutation><field
name="itemName">Tracker_Device_Region_Trigger</field></block></value></block></value><next><block
type="oh_log" id="Ole3*._aF%4rc5)5xbb2"><field
name="severity">info</field><value name="message"><shadow type="text"
id=".}tcn)wsC$2}Dt`r[478"><field name="TEXT">abc</field></shadow><block
type="oh_getitem_state" id="4x]8_;YyE4N_R.um]gp9"><value
name="itemName"><shadow type="oh_item"
id="[#!@og__`[7N]h?b.Jyf"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="fq+)ZtNKQ@|C3U0l1+R7"><mutation
itemName="Tracker_Device_System_Distance" itemLabel="System
Distance"></mutation><field
name="itemName">Tracker_Device_System_Distance</field></block></value></block></value><next><block
type="controls_if" id="D2`K:maRqe1|82z%Jjsr"><mutation
elseif="1"></mutation><value name="IF0"><block type="logic_compare"
id="iJeiAxe][uaB)m+wQraf"><field name="OP">LT</field><value
name="A"><block type="oh_getitem_state" id="dQivryc|mK1L@kX*Ik?4"><value
name="itemName"><shadow type="oh_item"
id="R)sApZr!u2.S.]ILtYx+"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="UT9B.2AWUpe;N3PDmI.h"><mutation
itemName="Tracker_Device_System_Distance" itemLabel="System
Distance"></mutation><field
name="itemName">Tracker_Device_System_Distance</field></block></value></block></value><value
name="B"><block type="text" id="iX8/3w^ieG9TKo]+NA8="><field
name="TEXT">15.0</field></block></value></block></value><value
name="IF1"><block type="logic_compare" id="t0)ypc(`t[I}^TKF?q95"><field
name="OP">EQ</field><value name="A"><block type="oh_getitem_state"
id="/3;WF`^feK8:am57T,{W"><value name="itemName"><shadow type="oh_item"
id="Ci2*%kv,7$d5.P1%W2pj"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="}$uz{Ek4^ehpjTFl9qxn"><mutation
itemName="Tracker_Device_Region_Trigger" itemLabel="Region
Trigger"></mutation><field
name="itemName">Tracker_Device_Region_Trigger</field></block></value></block></value><value
name="B"><block type="text" id="?Z=t3`nU*^D(C(ExLlCt"><field
name="TEXT">OFF</field></block></value></block></value><statement
name="DO1"><block type="oh_event" id="p{i`g^VnX]pp%yY1Iplx"><field
name="eventType">sendCommand</field><value name="value"><shadow
type="text" id="pYQ(s9cYCLH%JOp=x/QI"><field
name="TEXT">value</field></shadow><block type="text"
id="f)2bV$sl?ZEOl.g!|9M,"><field
name="TEXT">ON</field></block></value><value name="itemName"><shadow
type="oh_item" id=".IF^:Rmt,.DE^K[u7}VK"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="*ZgY%IP~NDk*NjUu.oNw"><mutation itemName="routine_entrata"
itemLabel="routine entrata"></mutation><field
name="itemName">routine_entrata</field></block></value></block></statement></block></next></block></next></block></xml>
type: application/javascript
script: >
console.info(items.getItem('Tracker_Device_Region_Trigger').state);
console.info(items.getItem('Tracker_Device_System_Distance').state);
if (items.getItem('Tracker_Device_System_Distance').state < '15.0') {
} else if (items.getItem('Tracker_Device_Region_Trigger').state == 'OFF') {
items.getItem('routine_entrata').sendCommand('ON');
}
type: script.ScriptAction