javascript conditionDescription:
The javascript condition checks the return value of a javascript function/expression.
Parent: all, any, condition, conditions, none, not , wait
Value (simple form): string specifying the javascript code to execute
Value (key/value form):
code: string, required, specifying the javascript code to executeinterval: time, optional, specifying the time interval between automatic refreshes (default: null)
interval is null, no automatic refreshes will be performedinterval has no unit, milliseconds is assumed# simple form
javascript: (string)
# simple example
javascript: |
const d = new Date();
return d.getDate() === 15;
# key/value form
javascript:
code: (string, required)
interval: (time, optional)
# key/value example
javascript:
code: |
const d = new Date();
return d.getDate() === 15;
interval: 30s
EXAMPLE:
- triggers:
- '[{anything}] is {#number} a multiple of {#number2}'
execute:
- if: [script: '({#number} % {#number2}) == 0' ]
then: [speak: 'Yes, {#number} is a multiple of {#number2}']
else: [speak: 'No, {#number} is not a multiple of {#number2}']
Status: ✅ IMPLEMENTED