Sure, not sure the camera_proxy_stream with api_password method is still working though.
Have not used that for a while but here is the python_script:
python_scripts\cameraloop.py:
# list of motion sensors correspond to cameras
motionList = data.get('motionList','group.garage_mvmnt,group.dining_mvmnt,group.kitchen_mvmnt')
motionList = motionList.split(",")
totcam=len(motionList)
maxlisti=totcam-1
# set the input_number.camera_loop
def set_loop(hass,loopid,state,chk):
hass.states.set('input_number.'+loopid,state, {
'initial': '0',
'min': '0',
'max': '10',
'step': '1',
'mode': 'slider',
'friendly_name': loopid,
'cnt': chk
})
return
chk=hass.states.get('input_number.camera_loop')
if ( chk is None ):
#start with [0] if not exist
set_loop(hass,'camera_loop',0,1)
else:
# increment the camera_loop
loopi=int(float(hass.states.get('input_number.camera_loop').state))
if loopi < maxlisti:
listi=loopi+1
else:
listi=0
while listi < 9:
if ( hass.states.get(motionList[listi]).state == 'off' or hass.states.get(motionList[listi]).state == 'not_home'):
set_loop(hass,'camera_loop',listi,1)
# logger.warning("chk found>>"+str(listi))
break
else:
if listi == loopi:
set_loop(hass,'camera_loop',9,1)
# logger.warning("chk 9>>")
break
elif listi == maxlisti:
listi=0
else:
listi=listi+1
Also, this is the automation used:
- id: camera loop
alias: camera loop
trigger:
- platform: time_pattern
seconds: '/5'
- platform: template
value_template: '{% if (is_state("input_number.camera_loop", "0") and is_state("group.carport_mvmnt", "on")) or
(is_state("input_number.camera_loop", "1") and is_state("group.dining_mvmnt", "on")) or
(is_state("input_number.camera_loop", "2") and is_state("group.kitchen_mvmnt", "on")) or
(is_state("input_number.camera_loop", "3") and is_state("group.liv_mvmnt", "on")) or
(is_state("input_number.camera_loop", "9") and (is_state("group.carport_mvmnt", "off") or
is_state("group.dining_mvmnt", "off") or is_state("group.kitchen_mvmnt", "off") or
is_state("group.liv_mvmnt", "off"))) %}true{% endif %}'
action:
- service: python_script.cameraloop
You can skip or modify the template platform your way to trigger immediate change in cameraloop.
Have fun.