ok, update on my search for the schedule times, I got this far, thanks to @pnbruckner 's command_line sensor support :
using:
- platform: template
sensors:
master_bedroom_night:
friendly_name: Master bedroom schedule night
value_template: >
{{states('sensor.master_bedroom_schedule')[2:-11]}}
master_bedroom_day:
friendly_name: Master bedroom schedule day
value_template: >
{{states('sensor.master_bedroom_schedule')[12:-1]}}
based on:
- platform: command_line
name: Master bedroom schedule
command: !secret master_bedroom_schedule
and secret:
master_bedroom_schedule: curl http://192.168.1.212/api/API/rules/20 | jq '.conditions[]|select(.address == "/config/localtime")|.value'
find the correct rules in the Hue api configuration…
I am not sure if and how I can use these times, which are strings still, but my goal is to have automatons trigger from them. So this looks very promising, thanks so far!
reason for this intermediary post is an issue though, several of the CC’s attributes are not created (though presence battery, on, and reachable are unaffected) and hence the template sensors create errors in the log:
and:
question for @robmarkcole and @yottatsa if this is to be expected? does my extra command_line sensor frustrate the CC? And if yes, could I prevent this is any way?
thanks for having a look!
just to be sure I tested 3 extra times, and can report it is consistent: each time I take out the |jq command line sensor, all attributes are there. use the |jq command line sensor and the attributes are gone.
maybe this way of pulling out the wanted data can be change into a
value_template: >
{{value_json.state.value}}
after all, and that wouldn’t hurt the CC sensors creation?
EDIT 2
changed to _X GET and now it works fine!:
master_bedroom_schedule: curl -X GET http://192.168.1.212/api/API/rules/20 | jq ‘.conditions[]|select(.address == “/config/localtime”)|.value’
can’t find the documentation on the -X GET necessity but will find out later.
_UPDATE_3
seems still a bit flakey, template sensors don’t always get created, and are only created when the motion sensors is set to on. Dint understand this at all yet… somehow the command_line sensors interferes with the regular CC created sensors, and their template sensors.
Still progress made on the timings. I can now set a trigger using:
{{now().time().strftime("%H:%M") == states('sensor.master_bedroom_schedule_day') }}
or
{{now().time().strftime("%H:%M") == states('sensor.master_bedroom_schedule_night')}}
since the Hue app doesn’t support seconds in the schedules, I took them out by means of:
- platform: template
sensors:
master_bedroom_schedule_night:
friendly_name: Master bedroom schedule night
value_template: >
{{states('sensor.master_bedroom_schedule')[2:-14]}}
master_bedroom_schedule_day:
friendly_name: Master bedroom schedule day
value_template: >
{{states('sensor.master_bedroom_schedule')[12:-4]}}
resulting example automation:
- alias: 'Weekend Switch Off Masterbedroom motion sensor'
id: 'Weekend Switch Off Masterbedroom motion sensor'
# initial_state: 'on'
trigger:
# platform: time
# at: '07:00:00' # the time set in the Hue app, which has only day setting, and doesn't recognize weekend
platform: template
value_template: >
{{now().time().strftime("%H:%M") == states('sensor.master_bedroom_schedule_day')}}
condition:
- condition: template
value_template: >
{{ is_state ('sensor.activity_selection', 'Slapen')}}
- condition: template
value_template: >
{{is_state('binary_sensor.workday_sensor','off') or
is_states('input_boolean.home_mode_vacation','on')}}
action:
- service: switch.turn_off
entity_id: switch.master_bedroom_motion_sensor_switch
- condition: template
value_template: >
{{ is_state('input_boolean.notify_system', 'on')}}
- service: notify.notify
data_template:
message: >
{{as_timestamp(now()) | timestamp_custom("%X") }}: Day Off, enjoy a longer sleep.
hope to be able to do that with a better json command string, but since I don’t have that yet, this will do?