Is “between” supposed to trigger?

I wrote a Rule that will set the Location mode and Home Monitor state according to time of day and who is/isn’t home. In one of the nests “if” has a between with 2 times. This doesn’t seem to trigger at either the start or end times, but will execute properly if one of the other “if”s trigger so I am guessing , no

I think, I need to “or” that between with 2 other “equals” to tigger at that start or end time, any inputs?

I use “between” with “changes” to make it trigger, otherwise it always seems to act as a precondition.

@AZSteve Always good if you can attach a screenshot of your Rule so we can see how you set it up. Blackout any info you don’t wish to be seen online. :slight_smile:

1 Like

Yup, between time ranges just seem to act as a pre-condition rather than a trigger.

@jkp, here is the Rule. I suspect that @sipuncher is correct


{
	"name": "Location Mode Updater (Mode)",
	"actions": [
		{
			"if": {
				"equals": {
					"left": {
						"device": {
							"devices": [
								"74a67738-af98-4089-af9e-c17b811c47ab",
								"ef2bcbf9-ca11-421a-88f7-2c9b9702f219"
							],
							"component": "main",
							"capability": "presenceSensor",
							"attribute": "presence",
							"trigger": "Always"
						}
					},
					"right": {
						"string": "not present"
					},
					"aggregation": "All"
				},
				"then": [
					{
						"location": {
							"security": {
								"armState": "ArmedAway"
							}
						}
					},
					{
						"location": {
							"mode": "99d86a45-853e-49e1-9129-72493ab0153c"
						}
					}
				],
				"else": [
					{
						"if": {
							"between": {
								"value": {
									"time": {
										"reference": "Now"
									}
								},
								"start": {
									"time": {
										"reference": "Noon",
										"offset": {
											"value": {
												"integer": 11
											},
											"unit": "Hour"
										}
									}
								},
								"end": {
									"time": {
										"reference": "Noon",
										"offset": {
											"value": {
												"integer": -5
											},
											"unit": "Hour"
										}
									}
								}
							},
							"then": [
								{
									"location": {
										"security": {
											"armState": "ArmedStay"
										}
									}
								},
								{
									"location": {
										"mode": "3f8418ca-1beb-474c-9640-fd2e013a94b2"
									}
								}
							],
							"else": [
								{
									"location": {
										"security": {
											"armState": "Disarmed"
										}
									}
								},
								{
									"location": {
										"mode": "39d2fbe6-c52b-4097-9115-85cc03c54c4c"
									}
								}
							]
						}
					}
				]
			}
		}
	]
}

to catch the 11pm time, i modified the Rule today like this… i then added another If\equals in the same Rule as an additional Action to catch the 7am time


{
	"name": "Location Mode Updater (Mode)",
	"actions": [
		{
			"if": {
				"or": [
					{
						"equals": {
							"left": {
								"datetime": {
									"reference": "Now"
								}
							},
							"right": {
								"datetime": {
									"reference": "Noon",
									"offset": {
										"value": {
											"integer": 11
										},
										"unit": "Hour"
									}
								}
							}
						}
					},
					{
						"between": {
							"value": {
								"time": {
									"reference": "Now"
								}
							},
							"start": {
								"time": {
									"reference": "Noon",
									"offset": {
										"value": {
											"integer": 11
										},
										"unit": "Hour"
									}
								}
							},
							"end": {
								"time": {
									"reference": "Noon",
									"offset": {
										"value": {
											"integer": -5
										},
										"unit": "Hour"
									}
								}
							}
						}
					}
				],
				"then": [
					{
						"location": {
							"security": {
								"armState": "ArmedAway"
							}
						}
					},
					{
						"location": {
							"mode": "99d86a45-853e-49e1-9129-72493ab0153c"
						}
					}
				],
				"else": [
					{
						"if": {
							"between": {
								"value": {
									"time": {
										"reference": "Now"
									}
								},
								"start": {
									"time": {
										"reference": "Noon",
										"offset": {
											"value": {
												"integer": 11
											},
											"unit": "Hour"
										}
									}
								},
								"end": {
									"time": {
										"reference": "Noon",
										"offset": {
											"value": {
												"integer": -5
											},
											"unit": "Hour"
										}
									}
								}
							},
							"then": [
								{
									"location": {
										"security": {
											"armState": "ArmedStay"
										}
									}
								},
								{
									"location": {
										"mode": "3f8418ca-1beb-474c-9640-fd2e013a94b2"
									}
								}
							],
							"else": [
								{
									"location": {
										"security": {
											"armState": "Disarmed"
										}
									}
								},
								{
									"location": {
										"mode": "39d2fbe6-c52b-4097-9115-85cc03c54c4c"
									}
								}
							]
						}
					}
				]
			}
		}
	]
}

and the additional if\equals


		{
			"if": {
				"and": [
					{
						"equals": {
							"left": {
								"datetime": {
									"reference": "Now"
								}
							},
							"right": {
								"datetime": {
									"reference": "Noon",
									"offset": {
										"value": {
											"integer": -5
										},
										"unit": "Hour"
									}
								}
							}
						}
					},
					{
						"equals": {
							"left": {
								"device": {
									"devices": [
										"74a67738-af98-4089-af9e-c17b811c47ab",
										"ef2bcbf9-ca11-421a-88f7-2c9b9702f219"
									],
									"component": "main",
									"capability": "presenceSensor",
									"attribute": "presence",
									"trigger": "Always"
								}
							},
							"right": {
								"string": "present"
							},
							"aggregation": "All"
						}
					}
				],
				"then": [
					{
						"location": {
							"security": {
								"armState": "Disarmed"
							}
						}
					},
					{
						"location": {
							"mode": "39d2fbe6-c52b-4097-9115-85cc03c54c4c"
						}
					}
				]
			}
		}

i tried the changes
between

{
	"if": {
		"changes": {
			"between": {
				"value": {
					"time": {
						"reference": "Now"
					}
				},
				"start": {
					"time": {
						"reference": "Noon",
						"offset": {
							"value": {
								"decimal": 11
							},
							"unit": "Hour"
						}
					}
				},
				"end": {
					"time": {
						"reference": "Noon",
						"offset": {
							"value": {
								"decimal": -5
							},
							"unit": "Hour"
						}
					}
				}
			}
		},
		"then": [
			{
				"location": {
					"security": {
						"armState": "ArmedStay"
					}
				}
			},
			{
				"location": {
					"mode": "3f8418ca-1beb-474c-9640-fd2e013a94b2"
				}
			}
		],
		"else": [
			{
				"location": {
					"security": {
						"armState": "Disarmed"
					}
				}
			},
			{
				"location": {
					"mode": "39d2fbe6-c52b-4097-9115-85cc03c54c4c"
				}
			}
		]
	}
}

that didn’t work.

I then tried ‘between’, which will work, if something else triggers… so it is definitely a pre-condition, but i coupled that with 2 every specific, these don’t seem to trigger at the time either.

{
	"name": "Location Mode Updater (Mode)",
	"actions": [
		{
			"every": {
				"specific": {
					"reference": "Noon",
					"offset": {
						"value": {
							"decimal": 11
						},
						"unit": "Hour"
					}
				},
				"actions": [
					{
						"location": {
							"security": {
								"armState": "ArmedStay"
							}
						}
					},
					{
						"location": {
							"mode": "3f8418ca-1beb-474c-9640-fd2e013a94b2"
						}
					}
				]
			}
		},
		{
			"every": {
				"specific": {
					"reference": "Noon",
					"offset": {
						"value": {
							"decimal": -5
						},
						"unit": "Hour"
					}
				},
				"actions": [
					{
						"location": {
							"security": {
								"armState": "Disarmed"
							}
						}
					},
					{
						"location": {
							"mode": "39d2fbe6-c52b-4097-9115-85cc03c54c4c"
						}
					}
				]
			}
		},
		{
			"if": {
				"equals": {
					"left": {
						"device": {
							"devices": [
								"a22fffbe-f6d0-427b-bf48-9746e5545216"
							],
							"component": "main",
							"capability": "switch",
							"attribute": "switch",
							"trigger": "Always"
						}
					},
					"right": {
						"string": "on"
					}
				},
				"then": [
					{
						"location": {
							"security": {
								"armState": "ArmedAway"
							}
						}
					},
					{
						"location": {
							"mode": "cf17bc21-d3c2-4f69-8443-752acac57cec"
						}
					}
				],
				"else": [
					{
						"if": {
							"equals": {
								"left": {
									"device": {
										"devices": [
											"74a67738-af98-4089-af9e-c17b811c47ab",
											"ef2bcbf9-ca11-421a-88f7-2c9b9702f219"
										],
										"component": "main",
										"capability": "presenceSensor",
										"attribute": "presence",
										"trigger": "Always"
									}
								},
								"right": {
									"string": "not present"
								},
								"aggregation": "All"
							},
							"then": [
								{
									"location": {
										"security": {
											"armState": "ArmedAway"
										}
									}
								},
								{
									"location": {
										"mode": "99d86a45-853e-49e1-9129-72493ab0153c"
									}
								}
							],
							"else": [
								{
									"if": {
										"between": {
											"value": {
												"time": {
													"reference": "Now"
												}
											},
											"start": {
												"time": {
													"reference": "Noon",
													"offset": {
														"value": {
															"decimal": 11
														},
														"unit": "Hour"
													}
												}
											},
											"end": {
												"time": {
													"reference": "Noon",
													"offset": {
														"value": {
															"decimal": -5
														},
														"unit": "Hour"
													}
												}
											}
										},
										"then": [
											{
												"location": {
													"security": {
														"armState": "ArmedStay"
													}
												}
											},
											{
												"location": {
													"mode": "3f8418ca-1beb-474c-9640-fd2e013a94b2"
												}
											}
										],
										"else": [
											{
												"location": {
													"security": {
														"armState": "Disarmed"
													}
												}
											},
											{
												"location": {
													"mode": "39d2fbe6-c52b-4097-9115-85cc03c54c4c"
												}
											}
										]
									}
								}
							]
						}
					}
				]
			}
		}
	]
}

This works for me.

{
  "if": {
    "changes": {
      "between": {
        "value": {
          "device": {
            "devices": [
              "780be2dd-29f0-4647-b5a1-3189751f2bc1"
            ],
            "component": "main",
            "capability": "temperatureMeasurement",
            "attribute": "temperature"
          }
        },
        "start": {
          "decimal": 23
        },
        "end": {
          "decimal": 80
        }
      }
    },

thanks @mrfitz98 , that didn’t seem to work, not sure if it is because it’s nested

if(VACATION BUTTON= ON) -> set VACATION mode and ARMED(Away)
    else if Everyone is Away -> set AWAY mode and ARMED(Away)
        else if time changed\between 11pm and 7 am  -> set NIGHT mode and ARMED(Stay)
           else -> set HOME mode and DISARMED

i did ultimately get it to work, although i don’t think it’s optimal as i had to repeat all the conditions

{
	"name": "Location Mode Updater (Mode)",
	"actions": [
		{
			"every": {
				"specific": {
					"reference": "Noon",
					"offset": {
						"value": {
							"decimal": 11
						},
						"unit": "Hour"
					}
				},
				"actions": [
					{
						"if": {
							"equals": {
								"left": {
									"device": {
										"devices": [
											"a22fffbe-f6d0-427b-bf48-9746e5545216"
										],
										"component": "main",
										"capability": "switch",
										"attribute": "switch",
										"trigger": "Always"
									}
								},
								"right": {
									"string": "on"
								}
							},
							"then": [
								{
									"location": {
										"security": {
											"armState": "ArmedAway"
										}
									}
								},
								{
									"location": {
										"mode": "cf17bc21-d3c2-4f69-8443-752acac57cec"
									}
								}
							],
							"else": [
								{
									"if": {
										"equals": {
											"left": {
												"device": {
													"devices": [
														"74a67738-af98-4089-af9e-c17b811c47ab",
														"ef2bcbf9-ca11-421a-88f7-2c9b9702f219"
													],
													"component": "main",
													"capability": "presenceSensor",
													"attribute": "presence",
													"trigger": "Always"
												}
											},
											"right": {
												"string": "not present"
											},
											"aggregation": "All"
										},
										"then": [
											{
												"location": {
													"security": {
														"armState": "ArmedAway"
													}
												}
											},
											{
												"location": {
													"mode": "99d86a45-853e-49e1-9129-72493ab0153c"
												}
											}
										],
										"else": [
											{
												"location": {
													"security": {
														"armState": "ArmedStay"
													}
												}
											},
											{
												"location": {
													"mode": "3f8418ca-1beb-474c-9640-fd2e013a94b2"
												}
											}
										]
									}
								}
							]
						}
					}
				]
			}
		},
		{
			"every": {
				"specific": {
					"reference": "Noon",
					"offset": {
						"value": {
							"decimal": -5
						},
						"unit": "Hour"
					}
				},
				"actions": [
					{
						"if": {
							"equals": {
								"left": {
									"device": {
										"devices": [
											"a22fffbe-f6d0-427b-bf48-9746e5545216"
										],
										"component": "main",
										"capability": "switch",
										"attribute": "switch",
										"trigger": "Always"
									}
								},
								"right": {
									"string": "on"
								}
							},
							"then": [
								{
									"location": {
										"security": {
											"armState": "ArmedAway"
										}
									}
								},
								{
									"location": {
										"mode": "cf17bc21-d3c2-4f69-8443-752acac57cec"
									}
								}
							],
							"else": [
								{
									"if": {
										"equals": {
											"left": {
												"device": {
													"devices": [
														"74a67738-af98-4089-af9e-c17b811c47ab",
														"ef2bcbf9-ca11-421a-88f7-2c9b9702f219"
													],
													"component": "main",
													"capability": "presenceSensor",
													"attribute": "presence",
													"trigger": "Always"
												}
											},
											"right": {
												"string": "not present"
											},
											"aggregation": "All"
										},
										"then": [
											{
												"location": {
													"security": {
														"armState": "ArmedAway"
													}
												}
											},
											{
												"location": {
													"mode": "99d86a45-853e-49e1-9129-72493ab0153c"
												}
											}
										],
										"else": [
											{
												"location": {
													"security": {
														"armState": "Disarmed"
													}
												}
											},
											{
												"location": {
													"mode": "39d2fbe6-c52b-4097-9115-85cc03c54c4c"
												}
											}
										]
									}
								}
							]
						}
					}
				]
			}
		},
		{
			"if": {
				"equals": {
					"left": {
						"device": {
							"devices": [
								"a22fffbe-f6d0-427b-bf48-9746e5545216"
							],
							"component": "main",
							"capability": "switch",
							"attribute": "switch",
							"trigger": "Always"
						}
					},
					"right": {
						"string": "on"
					}
				},
				"then": [
					{
						"location": {
							"security": {
								"armState": "ArmedAway"
							}
						}
					},
					{
						"location": {
							"mode": "cf17bc21-d3c2-4f69-8443-752acac57cec"
						}
					}
				],
				"else": [
					{
						"if": {
							"equals": {
								"left": {
									"device": {
										"devices": [
											"74a67738-af98-4089-af9e-c17b811c47ab",
											"ef2bcbf9-ca11-421a-88f7-2c9b9702f219"
										],
										"component": "main",
										"capability": "presenceSensor",
										"attribute": "presence",
										"trigger": "Always"
									}
								},
								"right": {
									"string": "not present"
								},
								"aggregation": "All"
							},
							"then": [
								{
									"location": {
										"security": {
											"armState": "ArmedAway"
										}
									}
								},
								{
									"location": {
										"mode": "99d86a45-853e-49e1-9129-72493ab0153c"
									}
								}
							],
							"else": [
								{
									"if": {
										"between": {
											"value": {
												"time": {
													"reference": "Now"
												}
											},
											"start": {
												"time": {
													"reference": "Noon",
													"offset": {
														"value": {
															"decimal": 11
														},
														"unit": "Hour"
													}
												}
											},
											"end": {
												"time": {
													"reference": "Noon",
													"offset": {
														"value": {
															"decimal": -5
														},
														"unit": "Hour"
													}
												}
											}
										},
										"then": [
											{
												"location": {
													"security": {
														"armState": "ArmedStay"
													}
												}
											},
											{
												"location": {
													"mode": "3f8418ca-1beb-474c-9640-fd2e013a94b2"
												}
											}
										],
										"else": [
											{
												"location": {
													"security": {
														"armState": "Disarmed"
													}
												}
											},
											{
												"location": {
													"mode": "39d2fbe6-c52b-4097-9115-85cc03c54c4c"
												}
											}
										]
									}
								}
							]
						}
					}
				]
			}
		}
	]
}

You’re right, I had to pull the “changes” trigger out of my 3 condition statements to be able to have it trigger.

if changes
then
if the other conditions
then actions

When I had my “changes” lumped in with my other conditions it didn’t trigger. In my case I also have a “changes not between” in my “else” to flip it back if it falls out of the target range. I use this to open or close my shades depending on the temperature.