HI,
what would be the API command to set the day schedule of a motion sensor?
this is the sensor:
{"name":"MotionSensor 48.day-on","owner":"redacted","created":"2019-05-01T07:44:00","lasttriggered":"none","timestriggered":0,"status":"enabled","recycle":true,"conditions":[{"address":"/config/localtime","operator":"in","value":"T07:00:00/T22:30:00"},{"address":"/sensors/48/state/presence","operator":"eq","value":"true"},{"address":"/sensors/48/state/presence","operator":"dx"},{"address":"/sensors/50/state/status","operator":"lt","value":"1"},{"address":"/sensors/49/state/dark","operator":"eq","value":"true"}],"actions":[{"address":"/groups/2/action","method":"PUT","body":{"scene":"xahsEsVMGanjhFk"}},{"address":"/sensors/50/state","method":"PUT","body":{"status":1}}]}
so I know I have to set
http://192.168.1.212/api/redacted/rules/15/
the Put command would be in this form:
http://192.168.1.212/api/redacted/{{ type }}/{{ id }}/{{ command }}
but I am struggling with the correct command.
Getting it is easy: {{ value_json.conditions[0].value }}
which is then returned as T07:00:00/T22:30:00
but I how can I set that day-time ?
for reference:
for this sensor at http://192.168.1.212/redacted/sensors/48
with response:
{"state":{"presence":null,"lastupdated":"none"},"swupdate":{"state":"noupdates","lastinstall":"2019-03-12T09:33:35"},"config":{"on":false,"battery":100,"reachable":true,"alert":"none","ledindication":false,"usertest":false,"sensitivity":2,"sensitivitymax":2,"pending":[]},"name":"Master bedroom sensor","type":"ZLLPresence","modelid":"SML001","manufacturername":"Philips","productname":"Hue motion sensor","swversion":"6.1.1.27575","uniqueid":"redacted","capabilities":{"certified":true}}
I can set eg sensitivity as follows:
script:
set_hue_sensitivity:
alias: Set Hue sensitivity
sequence:
service: rest_command.set_hue_command
data_template:
command: config
type: sensors
data: >
{% set mapper =
{ 'Low':'0',
'Medium':'1',
'High':'2' } %}
{% set state = states('input_select.select_hue_sensitivity') %}
{% set sensitivity = mapper[state] if state in mapper %}
{"sensitivity": {{sensitivity}} }
id: >
{% set mapper =
{ 'Laundry':'22',
'Dining table':'52',
'Auditorium':'44',
'Frontdoor':'60',
'Dorm':'56',
'Corridor':'5',
'Corridor terrace':'33',
'Master bedroom':'48',
'Corridor Office':'28',
'Control room':'7',
'Attic':'12' } %}
{% set state = states('input_select.select_hue_motion_sensor') %}
{% set id = mapper[state] if state in mapper %}
{{id}}
using that same rest command, I would need to adjust the above data_template to point to the value":“T07:00:00/T22:30:00”
guess I would need a way to replace the current schedule’s daypart (split at /) with the desired setting:
{% set schedule = ‘T06:04:00/T22:30:00’ %}
{% set alarm = states(‘sensor.alarmclock_wd_time’) %}
{{‘T’+alarm+ schedule[6:19]}}
or using an available schedule sensor:
{{states('sensor.master_bedroom_schedule_rst')}}
{% set schedule = states('sensor.master_bedroom_schedule_rst') %}
{% set alarm = states('sensor.alarmclock_wd_time') %}
{{schedule[0:10]+'T'+alarm+':00'}} or {{schedule.split('/')[0] + '/T'+alarm+':00'}}
thanks for having a look!