I am new at this for the Help Center and I hope that I am doing this correctly.
I have written code that works with MQTT that works great but I am looking to Automate it just a little further. I will take my motion sensor as the example because it litteraly goes on and off when it detects my movement in the room. I am hoping to find a way at trigging it once for a period of time and then reset itself after that. Here is the code that I presently have and if possible keep it all in on script.
- alias: GarageBackRoomMotion
id: Garage_BackRoom_Motion
trigger:- platform: mqtt
topic: tele/perrysbridge/RESULT
payload: āD2362Cā
value_template: ā{{ value_json.RfReceived.Data }}ā
for: 10 minutes
action: - service: media_player.turn_on
data_template:
entity_id:
media_player.living_room_speaker,
media_player.mini_bedroom,
media_player.mini_garage,
media_player.mini_kitchen,
media_player.master_bedroom_speaker - service: media_player.volume_set
data_template:
entity_id:
media_player.living_room_speaker,
media_player.mini_bedroom,
media_player.mini_garage,
media_player.mini_kitchen,
media_player.master_bedroom_speaker
volume_level: 0.6 - service: media_player.play_media
data_template:
entity_id:
media_player.living_room_speaker,
media_player.mini_bedroom,
media_player.mini_garage,
media_player.mini_kitchen,
media_player.master_bedroom_speaker
data:
media_content_id: /local/media/sound/15-back-door-motion.mp3
media_content_type: music - service: media_player.volume_set
data:
entity_id:
media_player.livingliving_room_speakerroom,
media_player.mini_bedroom,
media_player.mini_garage,
media_player.mini_kitchen,
media_player.master_bedroom_speaker
volume_level: 0.9
- platform: mqtt
I tried the for 10 minute delay but that seems not to be the answer to the problem that I have.