I have two kids (dragon!) in my home. With a lot of fun, I have a lot of stress too. One particular area of concern is their screen time.
In many cases I found my kids goes near to the TV and with the excessive joy they have, they don’t know they are very close to it.
As a modern day’s parent, I must tackle this issue and I did that using home assistant.
Objective:
To pause the TV playback while someone is near to the TV. Resume the playback while no-one is too close to the TV.
This case my kids shall not watch the TV while they are near to it. So once they are near, it will pause the playback and will resume while they are a bit far from the TV.
In many cases I found my kids goes near to the TV and with the excessive joy they have, they don’t know they are very close to it.
As a modern day’s parent, I must tackle this issue and I did that using home assistant.
Objective:
To pause the TV playback while someone is near to the TV. Resume the playback while no-one is too close to the TV.
This case my kids shall not watch the TV while they are near to it. So once they are near, it will pause the playback and will resume while they are a bit far from the TV.
List of tools I used
- NODE MCU ESP8266 (Link)
- Node MCU Development Kit V3 (Link)
- Ultrasonic Sensor (HC-SR04) (Link)
- BroadLink RM Pro (Link)
- Home Assistant (Link)
- ESP home (Link)
Process Followed:
ESP Home Code
Home Assistant Automation Code:
- Use ESP8266 on NodeMCU board with power adapter
- Use ESP Home to configure ESP8266 for Ultrasonic Sensor
- Learn RF code for play and pause from remote on Broadlink RM Pro and convert those code to BASE64 for home assistant
- Write an automation code for Play/Pause based on the Ultrasonic Sensor Data
- Testing and fixing the sensor on TV unit
ESP Home Code
sensor:
- platform: ultrasonic
trigger_pin: D1
echo_pin: D2
name: "Ultrasonic Sensor"
pulse_time: 10us
timeout: 20m
update_interval: 2s
Home Assistant Automation Code:
- alias: 'TV to Human Distance is Low'
trigger:
- platform: numeric_state
entity_id: sensor.ultrasonic_sensor
below: 1.2
for:
seconds: 3
action:
- service: switch.turn_on
entity_id: switch.tv_pause
- delay: '00:00:01'
- service: tts.google_say
data_template:
cache: true
entity_id: media_player.googlehome0666
message: "Hei kids, don't stand infront of the TV. Go back to Sofa"
- delay: '00:00:15'
- service: switch.turn_on
entity_id: switch.tv_play
Home Assistant Switch for Broadlink:
tv_play:
friendly_name: "TV Play"
command_on: 'JgBmAE4UFBQoExQUnFBQTQoExQTKBQUExQUJwANBQAA'
tv_pause:
friendly_name: "TV Pause"
command_on: 'JgBmAE8UKBBMoFCgTFBMUFCgTKBMoExQxUTKAANBQAA'
Comments
Post a Comment