i use Hue motion sensors, which I en/disable through api calls. I have set some global values the App, so the sensors act independently from HA also. But, in my scripts and scenes I need to override that (watching TV in the evening while the sensors are normally on and triggering the lights…)
Can you switch the sensors through HA?
this is what Hue uses:
switch:
- platform: command_line
switches:
frontdoor_motion_sensor_switch:
friendly_name: 'Frontdoor motion sensor switch'
command_on: >
curl -X PUT -d '{"on":true}' "http://192.168.1.212/api/key/sensors/5/config/"
command_off: >
curl -X PUT -d '{"on":false}' "http://192.168.1.212/api/key/sensors/5/config/"
command_state: curl http://192.168.1.212/api/key/sensors/5/
value_template: >
{{value_json.config.on}}
I then use these in scripts:
- alias: 'Frontdoor sensor Off when dogs free'
id: 'Frontdoor sensor Off when dogs free'
# initial_state: 'on'
trigger:
platform: state
entity_id: input_boolean.home_mode_dogs_free
condition:
condition: template
value_template: >
{{ is_state('group.family', 'not_home')}}
action:
- service_template: >
switch.turn_{{'off' if trigger.to_state.state == 'on' else 'on'}}
entity_id: switch.frontdoor_motion_sensor_switch
- condition: template
value_template: >
{{ is_state('input_boolean.notify_system', 'on')}}
- service: notify.notify
data_template:
message: >
Frontdoor motion sensor switched {{'off' if trigger.to_state.state == 'on' else 'on'}}, the dogs are free.
To get a bigger picture, I’d advise you to draw your desired schematics first, create some sort of rudimental architecture what you want to do in which situation. Then create that first setup, and build from there.
example, my main setup consists of this input_select:
input_select:
activity:
name: Activity selection
icon: mdi:home
options:
- Opstaan
- Aan de slag
- Gym
- Gaming
- Selamat makan
- Home theater
- Naar bed
and corresponding automation:
automation:
- alias: 'Activity selection'
id: 'Activity selection'
# hide_entity: True
initial_state: 'on'
trigger:
platform: state
entity_id: input_select.activity
condition:
condition: template
value_template: >
{{ states('input_select.activity') in
['Opstaan','Aan de slag','Home theater',
'Gym', 'Gaming', 'Selamat makan', 'Naar bed'] }}
action:
- service_template: >
script.{{ trigger.to_state.state | lower | replace(' ','_') }}
- delay:
seconds: 2
- service: mqtt.publish
data_template:
topic: 'activity_selection'
retain: true
payload: >
{{ states('input_select.activity') }}
# - service: python_script.summary
as you can see I have scripts for each of those activities, in which I again call scene for lighting schema’s and subordinate script for system settings like motion sensors etc etc…
I don’t use Lovelace yet, and have heavily invested in Tiles…
this is my Tiles setup for the activities, of which I posted the screenshot in one of the above replies:
homeassistant:
customize:
input_text.tiles_activity:
custom_ui_state_card: state-card-tiles
config:
columns: 4
# column_width: minmax(75px, 75px)
icon_size: 75px
entities:
- entity: script.opstaan_direct
style_template: >
if (entities['input_select.activity'].state === 'Opstaan') return 'background-color: #F0C209';
return 'background-color: #555B65';
image: /local/activities/opstaan.png
# label: Opstaan
- entity: script.aan_de_slag_direct
style_template: >
if (entities['input_select.activity'].state === 'Aan de slag') return 'background-color: #F0C209';
return 'background-color: #555B65';
image: /local/activities/aandeslag.png
# label: Aan de slag!
- entity: script.gym_direct
style_template: >
if (entities['input_select.activity'].state === 'Gym') return 'background-color: #F0C209';
return 'background-color: #555B65';
image: /local/activities/gym.png
# label: Gym
- entity: script.gaming_direct
style_template: >
if (entities['input_select.activity'].state === 'Gaming') return 'background-color: #F0C209';
return 'background-color: #555B65';
image: /local/activities/gaming.png
# label: Gaming
- entity: script.selamat_makan_direct
style_template: >
if (entities['input_select.activity'].state === 'Selamat makan') return 'background-color: #F0C209';
return 'background-color: #555B65';
image: /local/activities/selamatmakan.png
# label: Selamat makan
- entity: script.home_theater_direct
style_template: >
if (entities['input_select.activity'].state === 'Home theater') return 'background-color: #F0C209';
return 'background-color: #555B65';
image: /local/activities/hometheater.png
# label: Home theater
more_info: script.home_theater_direct
- entity: script.naar_bed_direct
style_template: >
if (entities['input_select.activity'].state === 'Naar bed') return 'background-color: #F0C209';
return 'background-color: #555B65';
image: /local/activities/naarbed.png
# label: Naar bed
Have a look and see if you can reuse things, or have questions.
cheers!