Closed littlbee closed 3 years ago
I have these defined as sensor
:
# Idle
- platform: history_stats
name: PS4 child idle
entity_id: media_player.ps4_child
state: "idle"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Standby
- platform: history_stats
name: PS4 child standby
entity_id: media_player.ps4_child
state: "standby"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Playing
- platform: history_stats
name: PS4 child Playing
entity_id: media_player.ps4_child
state: "playing"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Playing Weekly
- platform: history_stats
name: PS4 child Weekly (Playing)
entity_id: media_player.ps4_child
state: "playing"
type: time
start: "{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
# Media Content Type
- platform: template
sensors:
ps4_child_media_content_type:
friendly_name: "PS4 child - Media content type"
value_template: "{{ state_attr('media_player.ps4_child', 'media_content_type') }}"
# Playing (app)
- platform: history_stats
name: PS4 child Playing (app)
entity_id: sensor.ps4_child_media_content_type
state: "app"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Playing (game)
- platform: history_stats
name: PS4 child Playing (game)
entity_id: sensor.ps4_child_media_content_type
state: "game"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Weekly (app)
- platform: history_stats
name: PS4 child Weekly - App
entity_id: sensor.ps4_child_media_content_type
state: "app"
type: time
start: "{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
# Weekly (game)
- platform: history_stats
name: PS4 child Weekly - Game
entity_id: sensor.ps4_child_media_content_type
state: "game"
type: time
start: "{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
# Source
- platform: template
sensors:
ps4_child_source:
friendly_name: "PS4 child - Source"
value_template: "{{ state_attr('media_player.ps4_child', 'source') }}"
# Source (Netflix)
- platform: history_stats
name: PS4 child (Netflix)
entity_id: sensor.ps4_child_source
state: "Netflix"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Source Weekly (Netflix)
- platform: history_stats
name: PS4 child Weekly - Netflix
entity_id: sensor.ps4_child_source
state: "Netflix"
type: time
start: "{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
# Source (Disney+)
- platform: history_stats
name: PS4 child (Disney+)
entity_id: sensor.ps4_child_source
state: "Disney+"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Source Weekly (Disney+)
- platform: history_stats
name: PS4 child Weekly - Disney+
entity_id: sensor.ps4_child_source
state: "Disney+"
type: time
start: "{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
# Human readable played app time
- platform: template
sensors:
ps4_child_human_readable_app_time:
value_template: >-
{% set watched = ((states('sensor.ps4_child_playing_app') | float) * 60 * 60) %}
{%- set TIME_MAP = {
'h': (watched / 3600) % 24,
'm': (watched / 60) % 60
} -%}
{{ TIME_MAP.h | int }}:{{ '%02d' % TIME_MAP.m | int}}
ps4_child_human_readable_game_time:
value_template: >-
{% set played = ((states('sensor.ps4_child_playing_game') | float) * 60 * 60) %}
{%- set TIME_MAP = {
'h': (played / 3600) % 24,
'm': (played / 60) % 60
} -%}
{{ TIME_MAP.h | int }}:{{ '%02d' % TIME_MAP.m | int}}
# Human readable played app time weekly
- platform: template
sensors:
ps4_child_human_readable_app_time_weekly:
value_template: >-
{% set watched = ((states('sensor.ps4_child_weekly_app') | float) * 60 * 60) %}
{%- set TIME_MAP = {
'h': (watched / 3600) % 24,
'm': (watched / 60) % 60
} -%}
{{ TIME_MAP.h | int }}:{{ '%02d' % TIME_MAP.m | int}}
ps4_child_human_readable_game_time_weekly:
value_template: >-
{% set played = ((states('sensor.ps4_child_weekly_game') | float) * 60 * 60) %}
{%- set TIME_MAP = {
'h': (played / 3600) % 24,
'm': (played / 60) % 60
} -%}
{{ TIME_MAP.h | int }}:{{ '%02d' % TIME_MAP.m | int}}
These as input_datetime
:
ps4_child_game_time:
name: PS4 child - Game time
icon: mdi:sony-playstation
has_date: false
has_time: true
ps4_child_app_time:
name: PS4 child - APP time
icon: mdi:netflix
has_date: false
has_time: true
Then in the Lovelace I have:
type: horizontal-stack
title: Game time
cards:
- type: vertical-stack
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Used
icon: gamepad-variant
time_today: sensor.ps4_child_playing_game
- type: vertical-stack
cards:
- format: Time Left
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Left
icon: gamepad-variant
time_today: sensor.ps4_child_playing_game
max_today: input_datetime.ps4_child_game_time
- type: vertical-stack
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: This week
icon: gamepad-variant
time_today: sensor.ps4_child_weekly_game
Which translates to:
Then I also have these for Disney+ / Netflix times, in Lovelave:
type: horizontal-stack
title: Disney+ / Netlix
cards:
- type: vertical-stack
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Used
icon: youtube
time_today: sensor.ps4_child_playing_app
- type: vertical-stack
cards:
- format: Time Left
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Left
icon: youtube
time_today: sensor.ps4_child_playing_app
max_today: input_datetime.ps4_child_app_time
- type: vertical-stack
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: This week
icon: youtube
time_today: sensor.ps4_child_weekly_app
...which translates to:
Did this answer your question? 🤔
Also, this I used for development:
type: horizontal-stack
cards:
- type: vertical-stack
title: Today elapsed
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Played total
icon: gamepad-variant
time_today: sensor.ps4_child_playing_game
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Watched total
icon: youtube
time_today: sensor.ps4_child_playing_app
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Screentime total
icon: monitor-eye
time_today: sensor.ps4_child_playing
- type: vertical-stack
title: Today left
cards:
- format: Time Left
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Game time left
icon: gamepad-variant
time_today: sensor.ps4_child_playing_game
max_today: input_datetime.ps4_child_game_time
- format: Time Left
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Videos left
icon: youtube
time_today: sensor.ps4_child_playing_app
max_today: input_datetime.ps4_child_app_time
- format: Time Left
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Screentime left
icon: monitor-eye
time_today: sensor.ps4_child_playing
max_today: sensor.ps4_child_playing
- type: vertical-stack
title: Today total
cards:
- format: Time Elapsed
time_format: '01:05'
type: 'custom:elapsed-time-card'
name: Played total
icon: gamepad-variant
max_today: input_datetime.ps4_child_game_time
time_today: sensor.ps4_child_playing_game
- format: Time Elapsed
time_format: '01:05'
type: 'custom:elapsed-time-card'
name: Watched total
icon: youtube
time_today: sensor.ps4_child_playing_app
max_today: input_datetime.ps4_child_app_time
- format: Time Elapsed
time_format: '01:05'
type: 'custom:elapsed-time-card'
name: Screentime total
icon: monitor-eye
time_today: sensor.ps4_child_playing
- type: vertical-stack
title: This week elapsed
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Played total
icon: gamepad-variant
time_today: sensor.ps4_child_weekly_game
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Watched total
icon: youtube
time_today: sensor.ps4_child_weekly_app
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Screentime total
icon: monitor-eye
time_today: sensor.ps4_child_weekly_playing
- type: vertical-stack
title: This week elapsed
cards:
- format: Time Elapsed
time_format: '01:05'
type: 'custom:elapsed-time-card'
name: Played total
icon: gamepad-variant
time_today: sensor.ps4_child_weekly_game
- format: Time Elapsed
time_format: '01:05'
type: 'custom:elapsed-time-card'
name: Watched total
icon: youtube
time_today: sensor.ps4_child_weekly_app
- format: Time Elapsed
time_format: '01:05'
type: 'custom:elapsed-time-card'
name: Screentime total
icon: monitor-eye
time_today: sensor.ps4_child_weekly_playing
Which looks like this:
Just out of curiosity: what are you going to be using this for? 🙂 I initially developed this for myself, for the purpose of both tracking and limiting the game/video on demand times for our kid. Meaning that we have defined that the kid can play games for 2 hours and watch cartoons for 1 hour per day, and wanted to create a separate Lovelace panel for the kid to see how much of each time limit has they used/how much is still left.
On top of that we’ve limited the times when the PS4 can be powered on and when it will automatically power off. I can share these configuration/automation examples as well, in case interested.
I have also put some limits of play time to my son, I had already a daily and weekly sensor based on the playing state, but not as many sensors as you created. Most probably a bit out of laziness :-) But you are giving me a little boost and I will for sure add the missing sensors to be a better view. Next to this I have also put some automation to broadcast messages on Google Home when the playing time exceed the agreed limit + I can ask Google Home/Google Assistant how much time the playstation was on during the day.
Not sure If you get anything out of these, but I'll spam a bunch of configurations, automations, sensors, lovelace ui configs, etc. here, that we have defined. If you have anything you'd like me to breakdown/answer, feel free to ask 🙂
I'll try to gather everything related to the PS4 limitations.
sensors/ps4_child.yaml
# Idle
- platform: history_stats
name: PS4 child idle
entity_id: media_player.ps4_child
state: "idle"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Standby
- platform: history_stats
name: PS4 child standby
entity_id: media_player.ps4_child
state: "standby"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Playing
- platform: history_stats
name: PS4 child Playing
entity_id: media_player.ps4_child
state: "playing"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Playing Weekly
- platform: history_stats
name: PS4 child Weekly (Playing)
entity_id: media_player.ps4_child
state: "playing"
type: time
start: "{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
# Media Content Type
- platform: template
sensors:
ps4_child_media_content_type:
friendly_name: "PS4 child - Media content type"
value_template: "{{ state_attr('media_player.ps4_child', 'media_content_type') }}"
# Playing (app)
- platform: history_stats
name: PS4 child Playing (app)
entity_id: sensor.ps4_child_media_content_type
state: "app"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Playing (game)
- platform: history_stats
name: PS4 child Playing (game)
entity_id: sensor.ps4_child_media_content_type
state: "game"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Weekly (app)
- platform: history_stats
name: PS4 child Weekly - App
entity_id: sensor.ps4_child_media_content_type
state: "app"
type: time
start: "{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
# Weekly (game)
- platform: history_stats
name: PS4 child Weekly - Game
entity_id: sensor.ps4_child_media_content_type
state: "game"
type: time
start: "{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
# Source
- platform: template
sensors:
ps4_child_source:
friendly_name: "PS4 child - Source"
value_template: "{{ state_attr('media_player.ps4_child', 'source') }}"
# Source (Netflix)
- platform: history_stats
name: PS4 child (Netflix)
entity_id: sensor.ps4_child_source
state: "Netflix"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Source Weekly (Netflix)
- platform: history_stats
name: PS4 child Weekly - Netflix
entity_id: sensor.ps4_child_source
state: "Netflix"
type: time
start: "{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
# Source (Disney+)
- platform: history_stats
name: PS4 child (Disney+)
entity_id: sensor.ps4_child_source
state: "Disney+"
type: time
start: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"
end: "{{ now() }}"
# Source Weekly (Disney+)
- platform: history_stats
name: PS4 child Weekly - Disney+
entity_id: sensor.ps4_child_source
state: "Disney+"
type: time
start: "{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 86400 }}"
end: "{{ now() }}"
# Human readable played app time
- platform: template
sensors:
ps4_child_human_readable_app_time:
value_template: >-
{% set peliaika = ((states('sensor.ps4_child_playing_app') | float) * 60 * 60) %}
{%- set TIME_MAP = {
'h': (peliaika / 3600) % 24,
'm': (peliaika / 60) % 60
} -%}
{{ TIME_MAP.h | int }}:{{ '%02d' % TIME_MAP.m | int}}
ps4_child_human_readable_game_time:
value_template: >-
{% set peliaika = ((states('sensor.ps4_child_playing_game') | float) * 60 * 60) %}
{%- set TIME_MAP = {
'h': (peliaika / 3600) % 24,
'm': (peliaika / 60) % 60
} -%}
{{ TIME_MAP.h | int }}:{{ '%02d' % TIME_MAP.m | int}}
# Human readable played app time weekly
- platform: template
sensors:
ps4_child_human_readable_app_time_weekly:
value_template: >-
{% set peliaika = ((states('sensor.ps4_child_weekly_app') | float) * 60 * 60) %}
{%- set TIME_MAP = {
'h': (peliaika / 3600) % 24,
'm': (peliaika / 60) % 60
} -%}
{{ TIME_MAP.h | int }}:{{ '%02d' % TIME_MAP.m | int}}
ps4_child_human_readable_game_time_weekly:
value_template: >-
{% set peliaika = ((states('sensor.ps4_child_weekly_game') | float) * 60 * 60) %}
{%- set TIME_MAP = {
'h': (peliaika / 3600) % 24,
'm': (peliaika / 60) % 60
} -%}
{{ TIME_MAP.h | int }}:{{ '%02d' % TIME_MAP.m | int}}
scripts/ps4_child.yaml
ps4_child_kaynnista:
alias: PS4 child - Power on
mode: single
sequence:
- service: rest_command.control_ps
data:
target: child
user: hurrdurr
action: power-on
extra: ""
ps4_child_sammuta:
alias: PS4 child - Power off
mode: single
sequence:
- service: rest_command.control_ps
data:
target: child
user: hurrdurr
action: power-off
extra: ""
- service: scene.turn_on
entity_id: scene.child_scene_on_short
ps4_child_varota_60min:
alias: PS4 child - Warn for 60min left
mode: single
sequence:
- service: scene.turn_on
entity_id: scene.child_scene_ps4_60minutes
ps4_child_varota_5min:
alias: PS4 child - Warn for 5min left
mode: single
sequence:
- service: scene.turn_on
entity_id: scene.child_scene_ps4_5minutes
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: PS4 will power off in 5 minutes.
ps4_child_varota_1min:
alias: PS4 child - Warn for 1min left
mode: single
sequence:
- service: scene.turn_on
entity_id: scene.child_scene_ps4_1minutes
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: PS4 will power off in 1 minute.
ps4_child_varota_1800:
alias: PS4 child - Warn for 18:00
mode: single
sequence:
- service: scene.turn_on
entity_id: scene.child_scene_ps4_60minutes
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: It is 18:00, the PS4 will power off in 1 hour.
ps4_child_varota_1855:
alias: PS4 child - Warn for 18:55
mode: single
sequence:
- service: scene.turn_on
entity_id: scene.child_scene_ps4_5minutes
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: It is 18:55, the PS4 will power off in 5 minutes.
ps4_child_varota_1859:
alias: PS4 child - Warn for 18:59
mode: single
sequence:
- service: scene.turn_on
entity_id: scene.child_scene_ps4_1minutes
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: It is 18:59, the PS4 will power off in 1 minute.
ps4_child_sulje_sovellus:
alias: PS4 child - Sulje sovellus
mode: single
sequence:
- service: rest_command.control_ps
data:
target: child
user: hurrdurr
action: close-app
extra: ""
- wait_template: "{{ is_state('media_player.ps4_child', 'idle') }}"
timeout: "00:00:15"
- choose:
- conditions:
- condition: template
value_template: "{{ not wait.completed }}"
sequence:
- service: notify.kirbo_milli
data:
message: "PS4 child - Close game/app - failed"
- service: scene.turn_on
entity_id: scene.child_scene_ps4_1minutes
- service: script.turn_on
entity_id: script.ps4_child_sulje_kaikki_sovellukset
default:
- service: scene.turn_on
entity_id: scene.child_scene_on_short
ps4_child_sulje_kaikki_sovellukset:
alias: PS4 child - Sulje kaikki sovellukset
mode: single
sequence:
- service: rest_command.control_ps
data:
target: child
user: hurrdurr
action: close-all-apps
extra: ""
- wait_template: "{{ is_state('media_player.ps4_child', 'idle') }}"
timeout: "00:00:15"
- choose:
- conditions:
- condition: template
value_template: "{{ not wait.completed }}"
sequence:
- service: notify.kirbo_milli
data:
message: "PS4 child - Close all games/apps - failed"
- service: scene.turn_on
entity_id: scene.child_scene_ps4_1minutes
- service: script.turn_on
entity_id: script.ps4_child_sulje_sovellus
default:
- service: scene.turn_on
entity_id: scene.child_scene_on_short
ps4_child_pyyda_kaynnistysta:
alias: PS4 child - Ask for permission to power on PS4
mode: single
sequence:
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: Permission to play asked for, wait for the response.
- service: switch.turn_on
entity_id: switch.shelly_childn_tv
- condition: or
conditions:
- condition: template
value_template: "{{ (as_timestamp(states('input_datetime.ps4_child_turned_off')) > as_timestamp(states('input_datetime.ps4_child_asked_to_turn_on'))) }}"
- condition: template
value_template: "{{ (as_timestamp(now()) - as_timestamp(states('input_datetime.ps4_child_asked_to_turn_on'))) > 3600 }}"
- service: input_datetime.set_datetime
data:
entity_id: input_datetime.ps4_child_asked_to_turn_on
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
- service: notify.child
data:
title: PS4
message: Permission to play asked for, wait for the response.
- service: notify.mobile_app_kirbo_iphonexs
data:
title: PS4 child
message: Could you power on the PS4?
data:
push:
category: ps4_child_turn_on_actions
- service: notify.mobile_app_nokia_7_2
data:
title: PS4 child
message: Could you power on the PS4?
data:
actions:
- action: "PS4_child_TURN_ON"
title: "Power on"
- action: "PS4_child_DENIED"
title: "Nope"
scripts/child.yaml
child_tts:
alias: child TTS
description: "Send a TTS to child's Symfonisk"
fields:
message:
description: "The message content"
example: "Good day child!"
mode: single
sequence:
- service: media_player.volume_set
entity_id: media_player.child_symfonisk
data:
volume_level: 0.5
- service: tts.cloud_say
data:
entity_id: media_player.child_symfonisk
language: fi-FI
options:
gender: female
message: "{{ message }}"
scenes/child.yaml
- id: child_scene_ps4_60minutes
name: child scene PS4 60minutes
entities:
light.childn_huomio:
state: "on"
- id: child_scene_ps4_5minutes
name: child scene PS4 5minutes
entities:
light.childn_huomio:
state: "on"
- id: child_scene_ps4_1minutes
name: child scene PS4 1minutes
entities:
light.childn_huomio:
state: "on"
automations/ps4_child.yaml
- id: ps4_child_playing_app_or_game_over_time
alias: PS4 child - Playing APP or Game over time
trigger:
- platform: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- platform: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- platform: template
value_template: "{{ states('sensor.ps4_child_playing_game') | float * 60 >= (states.input_datetime.ps4_child_game_time.attributes.timestamp | int / 60) }}"
- platform: template
value_template: "{{ states('sensor.ps4_child_playing_app') | float * 60 >= (states.input_datetime.ps4_child_app_time.attributes.timestamp | int / 60) }}"
- platform: time_pattern
minutes: "*"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: or
conditions:
- condition: and
conditions:
- condition: template
value_template: "{{ states('sensor.ps4_child_media_content_type') == 'app' }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_playing_app') | float * 60 >= (states.input_datetime.ps4_child_app_time.attributes.timestamp | int / 60) }}"
- condition: and
conditions:
- condition: template
value_template: "{{ states('sensor.ps4_child_media_content_type') == 'game' }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_playing_game') | float * 60 >= (states.input_datetime.ps4_child_game_time.attributes.timestamp | int / 60) }}"
action:
- service: notify.kirbo_milli_child_kaikki
data:
message: >
{% if states('sensor.ps4_child_media_content_type') == 'game' %}
Game time exceeded, game will be closed now
{% elif states('sensor.ps4_child_media_content_type') == 'app' %}
Disney+/Netflix time exceeded, application will be closed now
{% endif %}
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: >
{% if states('sensor.ps4_child_media_content_type') == 'game' %}
Game time exceeded, game will be closed now
{% elif states('sensor.ps4_child_media_content_type') == 'app' %}
Disney+/Netflix time exceeded, application will be closed now
{% endif %}
- service: script.turn_on
entity_id: script.ps4_child_sulje_sovellus
- id: ps4_child_both_limits_exceeded
alias: PS4 child - Both limits exceeded
trigger:
- platform: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- platform: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- platform: template
value_template: "{{ states('sensor.ps4_child_playing_game') | float * 60 >= (states.input_datetime.ps4_child_game_time.attributes.timestamp | int / 60) }}"
- platform: template
value_template: "{{ states('sensor.ps4_child_playing_app') | float * 60 >= (states.input_datetime.ps4_child_app_time.attributes.timestamp | int / 60) }}"
- platform: time_pattern
minutes: "*"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_playing_game') | float * 60 >= (states.input_datetime.ps4_child_game_time.attributes.timestamp | int / 60) }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_playing_app') | float * 60 >= (states.input_datetime.ps4_child_app_time.attributes.timestamp | int / 60) }}"
action:
- service: notify.kirbo_milli_child_kaikki
data:
message: Game time AND Disney+/Netflix time exceeded, the PS4 will be powered off now.
- service: script.turn_on
entity_id: script.ps4_child_sammuta
- id: ps4_child_out_of_time_range
alias: PS4 child - Out of time range
trigger:
- platform: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- platform: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- platform: time_pattern
minutes: "*"
- platform: template
value_template: "{{ now().strftime('%H%M%S')|int == strptime(states('input_datetime.ps4_child_will_be_turned_off'), '%H:%M:%S').strftime('%H%M%S')|int }}"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: or
conditions:
- condition: template
value_template: "{{ now().strftime('%H%M%S')|int >= strptime(states('input_datetime.ps4_child_will_be_turned_off'), '%H:%M:%S').strftime('%H%M%S')|int }}"
- condition: template
value_template: "{{ now().strftime('%H%M%S')|int < strptime(states('input_datetime.ps4_child_can_be_turned_on'), '%H:%M:%S').strftime('%H%M%S')|int }}"
action:
- service: notify.kirbo_milli_child_kaikki
data:
message: >
{% if now().strftime('%H%M%S')|int >= strptime(states('input_datetime.ps4_child_will_be_turned_off'), "%H:%M:%S").strftime('%H%M%S')|int %}
The time is {{ now().strftime('%H:%M') }}. PS4 will be turned off after {{ strptime(states('input_datetime.ps4_child_will_be_turned_off'), "%H:%M:%S").strftime('%H:%M') }}!
{% elif now().strftime('%H%M%S')|int < strptime(states('input_datetime.ps4_child_can_be_turned_on'), "%H:%M:%S").strftime('%H%M%S')|int %}
The time is {{ now().strftime('%H:%M') }}. PS4 will be turned of before {{ strptime(states('input_datetime.ps4_child_can_be_turned_on'), "%H:%M:%S").strftime('%H:%M') }}!
{% endif %}
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: >
{% if now().strftime('%H%M%S')|int >= strptime(states('input_datetime.ps4_child_will_be_turned_off'), "%H:%M:%S").strftime('%H%M%S')|int %}
The time is {{ now().strftime('%H:%M') }}. PS4 will be turned off after {{ strptime(states('input_datetime.ps4_child_will_be_turned_off'), "%H:%M:%S").strftime('%H:%M') }}!
{% elif now().strftime('%H%M%S')|int < strptime(states('input_datetime.ps4_child_can_be_turned_on'), "%H:%M:%S").strftime('%H%M%S')|int %}
The time is {{ now().strftime('%H:%M') }}. PS4 will be turned of before {{ strptime(states('input_datetime.ps4_child_can_be_turned_on'), "%H:%M:%S").strftime('%H:%M') }}!
{% endif %}
- service: script.turn_on
entity_id: script.ps4_child_sammuta
- id: ps4_child_warning_1800
alias: PS4 child - Warning 18:00
trigger:
- platform: time
at: "18:00:00"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_60minutes_app', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_60minutes_app', 'last_triggered')) > 14400 }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_60minutes_game', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_60minutes_game', 'last_triggered')) > 14400 }}"
action:
- service: script.turn_on
entity_id: script.ps4_child_varota_1800
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: The time is 18:00, the PS4 will be turned off in 1 hour.
- id: ps4_child_warning_1855
alias: PS4 child - Warning 18:55
trigger:
- platform: time
at: "18:55:00"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_5minutes_app', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_5minutes_app', 'last_triggered')) > 14400 }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_5minutes_game', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_5minutes_game', 'last_triggered')) > 14400 }}"
action:
- service: script.turn_on
entity_id: script.ps4_child_varota_1855
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: The time is 18:55, the PS4 will be turned off in 5 minutes.
- id: ps4_child_warning_1859
alias: PS4 child - Warning 18:59
trigger:
- platform: time
at: "18:59:00"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_1minutes_app', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_1minutes_app', 'last_triggered')) > 14400 }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_1minutes_game', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_1minutes_game', 'last_triggered')) > 14400 }}"
action:
- service: script.turn_on
entity_id: script.ps4_child_varota_1859
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: The time is 18:59, the PS4 will be turned off in 1 minute.
- id: ps4_child_warning_app_half
alias: PS4 child - Warning half (app)
trigger:
- platform: template
value_template: "{{ ((states('sensor.ps4_child_playing_app')|float) * 60)|int == ((states.input_datetime.ps4_child_app_time.attributes.timestamp | int / 60) / 2) }}"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_1800', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_1800', 'last_triggered')) > 14400 }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_media_content_type') == 'app' }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_playing_app') | float * 60 >= ((states.input_datetime.ps4_child_app_time.attributes.timestamp | int / 60) / 2) }}"
action:
- service: script.turn_on
entity_id: script.ps4_child_varota_60min
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: Half off the Disney+/Netflix time has been used.
- id: ps4_child_warning_5minutes_app
alias: PS4 child - Warning 5minutes (app)
trigger:
- platform: template
value_template: "{{ ((states('sensor.ps4_child_playing_app')|float) * 60)|int == ((states.input_datetime.ps4_child_app_time.attributes.timestamp | int / 60) - 5) }}"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_1855', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_1855', 'last_triggered')) > 14400 }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_media_content_type') == 'app' }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_playing_app') | float * 60 >= ((states.input_datetime.ps4_child_app_time.attributes.timestamp | int / 60) - 5) }}"
action:
- service: script.turn_on
entity_id: script.ps4_child_varota_5min
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: Closing the application in 5 minutes.
- id: ps4_child_warning_1minutes_app
alias: PS4 child - Warning 1minutes (app)
trigger:
- platform: template
value_template: "{{ ((states('sensor.ps4_child_playing_app')|float) * 60)|int == ((states.input_datetime.ps4_child_app_time.attributes.timestamp | int / 60) - 1) }}"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_1859', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_1859', 'last_triggered')) > 14400 }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_media_content_type') == 'app' }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_playing_app') | float * 60 >= ((states.input_datetime.ps4_child_app_time.attributes.timestamp | int / 60) - 1) }}"
action:
- service: script.turn_on
entity_id: script.ps4_child_varota_1min
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: Closing the application in 1 minute.
- id: ps4_child_warning_game_half
alias: PS4 child - Warning half (game)
trigger:
- platform: template
value_template: "{{ ((states('sensor.ps4_child_playing_game')|float) * 60)|int == ((states.input_datetime.ps4_child_game_time.attributes.timestamp | int / 60) / 2) }}"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_1800', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_1800', 'last_triggered')) > 14400 }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_media_content_type') == 'game' }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_playing_game') | float * 60 >= ((states.input_datetime.ps4_child_game_time.attributes.timestamp | int / 60) / 2) }}"
action:
- service: script.turn_on
entity_id: script.ps4_child_varota_60min
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: Half off the game time used.
- id: ps4_child_warning_5minutes_game
alias: PS4 child - Warning 5minutes (game)
trigger:
- platform: template
value_template: "{{ ((states('sensor.ps4_child_playing_game')|float) * 60)|int == ((states.input_datetime.ps4_child_game_time.attributes.timestamp | int / 60) - 5) }}"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_1855', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_1855', 'last_triggered')) > 14400 }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_media_content_type') == 'game' }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_playing_game') | float * 60 >= ((states.input_datetime.ps4_child_game_time.attributes.timestamp | int / 60) - 5) }}"
action:
- service: script.turn_on
entity_id: script.ps4_child_varota_5min
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: Game will be closed in 5 minutes.
- id: ps4_child_warning_1minutes_game
alias: PS4 child - Warning 1minutes (game)
trigger:
- platform: template
value_template: "{{ ((states('sensor.ps4_child_playing_game')|float) * 60)|int == ((states.input_datetime.ps4_child_game_time.attributes.timestamp | int / 60) - 1) }}"
condition:
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'standby') }}"
- condition: template
value_template: "{{ not is_state('media_player.ps4_child', 'unknown') }}"
- condition: template
value_template: "{{ state_attr('automation.ps4_child_warning_1859', 'last_triggered') is none or as_timestamp(now()) - as_timestamp(state_attr('automation.ps4_child_warning_1859', 'last_triggered')) > 14400 }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_media_content_type') == 'game' }}"
- condition: template
value_template: "{{ states('sensor.ps4_child_playing_game') | float * 60 >= ((states.input_datetime.ps4_child_game_time.attributes.timestamp | int / 60) - 1) }}"
action:
- service: script.turn_on
entity_id: script.ps4_child_varota_1min
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: Game will be closed in 1 minute.
- id: ps4_child_reset_game_time
alias: PS4 child - Reset game time
trigger:
- platform: time
at: "00:00:00"
action:
- service: input_datetime.set_datetime
data:
entity_id: input_datetime.ps4_child_game_time
time: "{{ states('input_datetime.ps4_child_game_time_default') }}"
- id: ps4_child_reset_app_time
alias: PS4 child - Reset APP time
trigger:
- platform: time
at: "00:00:00"
action:
- service: input_datetime.set_datetime
data:
entity_id: input_datetime.ps4_child_app_time
time: "{{ states('input_datetime.ps4_child_app_time_default') }}"
- id: ps4_child_turned_off
alias: PS4 child - Turned off
trigger:
- platform: state
entity_id: media_player.ps4_child
to:
- standby
- unknown
action:
- service: input_datetime.set_datetime
data:
entity_id: input_datetime.ps4_child_turned_off
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
- service: switch.turn_off
entity_id: switch.shelly_childn_tv
- id: ps4_child_turned_on
alias: PS4 child - Turned on
trigger:
- platform: state
entity_id: media_player.ps4_child
to: idle
action:
- service: switch.turn_on
entity_id: switch.shelly_childn_tv
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: PS4 powered on.
- id: ps4_child_flash_yellow_short
alias: PS4 child - Flash Yellow Short
trigger:
platform: event
event_type: call_service
event_data:
service_data:
entity_id: [scene.child_scene_ps4_60minutes]
domain: scene
service: turn_on
action:
- service: light.turn_on
entity_id:
- light.childn_huomio
data:
entity_id: light.childn_huomio
flash: short
color_name: yellow
- id: ps4_child_flash_long_orange
alias: PS4 child - Flash Orange Long
trigger:
platform: event
event_type: call_service
event_data:
service_data:
entity_id: [scene.child_scene_ps4_5minutes]
domain: scene
service: turn_on
action:
- service: light.turn_on
entity_id:
- light.childn_huomio
data:
entity_id: light.childn_huomio
flash: long
color_name: orange
- id: ps4_child_flash_long_red
alias: PS4 child - Flash Red Long
trigger:
platform: event
event_type: call_service
event_data:
service_data:
entity_id: [scene.child_scene_ps4_1minutes]
domain: scene
service: turn_on
action:
- service: light.turn_on
entity_id:
- light.childn_huomio
data:
entity_id: light.childn_huomio
flash: long
color_name: red
configurations/input_datetime.yaml
ps4_child_game_time:
name: PS4 child - Game time
icon: mdi:sony-playstation
has_date: false
has_time: true
ps4_child_app_time:
name: PS4 child - APP time
icon: mdi:netflix
has_date: false
has_time: true
ps4_child_game_time_default:
name: PS4 child - Game time default
icon: mdi:sony-playstation
has_date: false
has_time: true
ps4_child_app_time_default:
name: PS4 child - APP time default
icon: mdi:netflix
has_date: false
has_time: true
ps4_child_turned_off:
name: PS4 child - Turned Off
has_date: true
has_time: true
ps4_child_asked_to_turn_on:
name: PS4 child - Asked to turn on
has_date: true
has_time: true
ps4_child_can_be_turned_on:
name: PS4 child - Can be turned on
has_date: false
has_time: true
ps4_child_will_be_turned_off:
name: PS4 child - Will be turned off
has_date: false
has_time: true
Then I have on a separate Raspberry Pi 3 running one of my own Bash script, which uses PS4-waker and a script for using it:
configurations/rest_command.yaml
control_ps:
url: "http://192.168.1.200:3000/control_ps"
method: POST
content_type: "application/json; charset=utf-8"
payload: >
{
"target": "{{ target }}",
"user": "{{ user }}",
"action": "{{ action }}",
"extra": "{{ extra }}"
}
The Lovelace UI that we use to manage the limitations and stuff:
- title: Child
path: child
icon: 'fas:child'
visible:
- user: <retained>
badges: []
cards:
- type: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: button
entity: scene.child_scene_on_short
name: Homework
icon_height: 50px
icon: 'mdi:school'
tap_action:
action: call-service
service: scene.turn_on
service_data:
entity_id: scene.child_scene_on_short
transition: 0.5
- type: button
entity: scene.child_scene_dim_up_short
name: Chill
icon_height: 50px
icon: 'mdi:emoticon-cool'
tap_action:
action: call-service
service: scene.turn_on
service_data:
entity_id: scene.child_scene_dim_up_short
transition: 0.5
- type: button
entity: scene.child_scene_dim_down_short
name: Reading
show_state: false
icon_height: 50px
icon: 'mdi:book'
tap_action:
action: call-service
service: scene.turn_on
service_data:
entity_id: scene.child_scene_dim_down_short
transition: 0.5
- type: button
entity: scene.child_scene_off_short
name: Night light
icon_height: 50px
tap_action:
action: call-service
service: scene.turn_on
service_data:
entity_id: scene.child_scene_off_short
transition: 0.5
icon: 'mdi:bed'
- type: glance
entities:
- entity: media_player.ps4_child
name: PS4 child
- entity: switch.shelly_childn_tv
name: Child TV
- entity: light.childn_huomio
name: Lightstrip
- entity: light.childn_yovalo
name: Bed light
- entity: light.childn_kattovalo
name: Roof top
state_color: true
- type: 'custom:mini-media-player'
entity: media_player.ps4_child
group: true
artwork: full-cover-fit
info: true
hide:
volume: true
controls: true
shortcuts:
columns: 3
buttons:
- type: service
name: Power On
id: rest_command.control_ps
data:
target: child
user: hurrdurr
action: power-on
extra: ''
- type: service
name: Close App
id: rest_command.control_ps
data:
target: child
user: hurrdurr
action: close-app
extra: ''
- type: service
name: Power off
id: rest_command.control_ps
data:
target: child
user: hurrdurr
action: power-off
extra: ''
- type: service
name: Urpo Uno
id: rest_command.control_ps
data:
target: child
user: urpo_uno
action: login
extra: ''
- type: service
name: Urpo Duo
id: rest_command.control_ps
data:
target: child
user: urpo_duo
action: login
extra: ''
- type: service
name: Urpo Trio
id: rest_command.control_ps
data:
target: child
user: urpo_trio
action: login
extra: ''
- type: vertical-stack
cards:
- type: 'custom:time-picker-card'
entity: input_datetime.ps4_child_game_time
hour_mode: 24
name: Game time today
hour_step: 1
minute_step: 5
second_step: 5
layout:
embedded: false
align_controls: right
name: inside
hide:
seconds: true
link_values: false
- type: horizontal-stack
cards:
- type: vertical-stack
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Played
icon: gamepad-variant
time_today: sensor.ps4_child_playing_game
- type: vertical-stack
cards:
- format: Time Left
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Left
icon: gamepad-variant
time_today: sensor.ps4_child_playing_game
max_today: input_datetime.ps4_child_game_time
- type: vertical-stack
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: This week
icon: gamepad-variant
time_today: sensor.ps4_child_weekly_game
- type: history-graph
entities:
- entity: sensor.ps4_child_playing_game
name: Played
hours_to_show: 24
refresh_interval: 1
- type: horizontal-stack
cards:
- type: vertical-stack
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Screentime today
icon: monitor-eye
time_today: sensor.ps4_child_playing
- type: vertical-stack
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: This week
icon: monitor-eye
time_today: sensor.ps4_child_weekly_playing
- type: history-graph
entities:
- entity: media_player.ps4_child
name: Status
- entity: sensor.ps4_child_media_content_type
name: Media type
- entity: sensor.ps4_child_source
name: Source
hours_to_show: 24
refresh_interval: 0
- type: vertical-stack
cards:
- type: 'custom:time-picker-card'
entity: input_datetime.ps4_child_app_time
hour_mode: 24
name: Disney+ / Netflix today
hour_step: 1
minute_step: 5
second_step: 5
layout:
embedded: false
name: inside
align_controls: right
hide:
seconds: true
link_values: false
- type: horizontal-stack
cards:
- type: vertical-stack
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Watched
icon: youtube
time_today: sensor.ps4_child_playing_app
- type: vertical-stack
cards:
- format: Time Left
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Left
icon: youtube
time_today: sensor.ps4_child_playing_app
max_today: input_datetime.ps4_child_app_time
- type: vertical-stack
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: This week
icon: youtube
time_today: sensor.ps4_child_weekly_app
- type: history-graph
entities:
- entity: sensor.ps4_child_playing_app
name: In total
- entity: sensor.ps4_child_netflix
name: Netflix
- entity: sensor.ps4_child_disney
name: Disney+
hours_to_show: 24
refresh_interval: 1
- type: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: 'custom:time-picker-card'
entity: input_datetime.ps4_child_can_be_turned_on
hour_mode: 24
name: Can be powered on after
hour_step: 1
minute_step: 5
second_step: 5
layout:
embedded: false
name: header
align_controls: center
hide:
seconds: true
name: false
link_values: false
- type: 'custom:time-picker-card'
entity: input_datetime.ps4_child_will_be_turned_off
hour_mode: 24
name: Will be powered off after
hour_step: 1
minute_step: 5
second_step: 5
layout:
embedded: false
hide:
seconds: true
name: false
link_values: false
- type: horizontal-stack
cards:
- type: 'custom:time-picker-card'
entity: input_datetime.ps4_child_game_time_default
hour_mode: 24
name: Default game time daily
hour_step: 1
minute_step: 5
second_step: 5
layout:
embedded: null
name: header
align_controls: center
hide:
seconds: true
name: false
link_values: false
- type: 'custom:time-picker-card'
entity: input_datetime.ps4_child_app_time_default
hour_mode: 24
name: Default cartoon time daily
hour_step: 1
minute_step: 5
second_step: 5
layout:
embedded: null
name: header
align_controls: center
hide:
seconds: true
name: false
link_values: false
- type: 'custom:mini-media-player'
entity: media_player.child_symfonisk
artwork: full-cover-fit
info: true
volume_step: '1'
max_volume: '100'
min_volume: '0'
group: false
volume_stateless: false
- type: vertical-stack
cards:
- type: entities
entities:
- entity: device_tracker.child_huawei_2
name: At home
- entity: sensor.child_huawei_geocoded_location
name: Location
- entity: sensor.child_huawei_seuraava_halytys
name: Next alarm
- entity: sensor.child_huawei_akun_varaustaso
name: Battery Reservation
- entity: sensor.child_huawei_akun_tila
name: Battery status
- entity: binary_sensor.child_huawei_interactive
name: Screen on
- entity: binary_sensor.child_huawei_power_save
name: Powersaver mode
- entity: sensor.child_huawei_ulkoinen_tallennustila
name: External storage left
- entity: sensor.child_huawei_sisainen_tallennustila
name: Internal storage left
- entity: sensor.child_huawei_ringer_mode
name: Ringer
- entity: sensor.child_been_home_for_last_12h
name: At home for past 12h
- entity: sensor.child_kotiin_kavellen
secondary_info: distance
name: At home by walking
- entity: sensor.child_kotiin_pyoralla
name: At home by bicycle
- entity: sensor.child_kotiin_autolla
name: At home by car
- entity: sensor.child_to_home
name: At home by car (Waze)
title: Phone
state_color: false
..and it looks like this:
The Lovelace UI that the kid has on their tablet is like this:
- title: Child Tablet
path: child-tablet
icon: 'fas:tablet'
panel: true
visible:
- user: <retained>
badges: []
cards:
- type: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: horizontal-stack
cards:
- type: vertical-stack
cards:
- type: 'custom:clock-card'
time_zone: Europe/Helsinki
size: 190
- type: horizontal-stack
cards:
- type: button
entity: light.childn_huomio
name: Lightstrip
tap_action:
action: toggle
hold_action:
action: none
show_state: true
- type: button
entity: light.childn_yovalo
name: Bed light
hold_action:
action: more-info
show_state: true
- type: button
entity: light.childn_kattovalo
name: Roof top
show_state: true
- type: horizontal-stack
cards:
- type: button
entity: scene.child_scene_on_short
name: Homework
icon_height: 64px
icon: 'mdi:school'
tap_action:
action: call-service
service: scene.turn_on
service_data:
entity_id: scene.child_scene_on_short
transition: 0.5
- type: button
entity: scene.child_scene_dim_up_short
name: Chill
icon_height: 64px
icon: 'mdi:emoticon-cool'
tap_action:
action: call-service
service: scene.turn_on
service_data:
entity_id: scene.child_scene_dim_up_short
transition: 0.5
- type: button
entity: scene.child_scene_dim_down_short
name: Reading
show_state: false
icon_height: 64px
icon: 'mdi:book'
tap_action:
action: call-service
service: scene.turn_on
service_data:
entity_id: scene.child_scene_dim_down_short
transition: 0.5
- type: button
entity: scene.child_scene_off_short
name: Night light
icon_height: 64px
tap_action:
action: call-service
service: scene.turn_on
service_data:
entity_id: scene.child_scene_off_short
transition: 0.5
icon: 'mdi:bed'
- type: glance
entities:
- entity: sensor.child_huawei_akun_varaustaso
name: Battery reservation
- entity: binary_sensor.child_huawei_latautuu
name: Charging
- entity: sensor.child_huawei_seuraava_halytys
name: Next alarm
state_color: true
show_state: true
show_icon: true
show_name: true
- type: grid
columns: 2
cards:
- type: button
tap_action:
action: call-service
service: script.ps4_child_pyyda_kaynnistysta
entity: script.ps4_child_pyyda_kaynnistysta
name: Could I play PS4?
icon: 'mdi:sony-playstation'
show_state: false
show_icon: true
show_name: true
icon_height: 108px
- reload_interval: '0'
reload_delay: '1000'
type: 'custom:reload-button'
tap_action:
action: call-service
service: script.reload
name: Reload page
icon: refresh
pathname: /lovelace/child-tabletti
format: 'No'
reload_on_click: 'Yes'
reload_on_reconnect: 'Yes'
reload_on_lovelace_update: 'Yes'
- type: vertical-stack
cards:
- type: 'custom:atomic-calendar-revive'
entities: []
defaultMode: Calendar
language: fi
calShowDescription: false
showLastCalendarWeek: false
disableCalEventLink: false
disableCalLocationLink: false
firstDayOfWeek: 1
maxDaysToShow: 7
showLoader: true
showDate: true
sortByStartTime: false
showDeclined: false
hideFinishedEvents: false
showRelativeTime: false
showFullDayProgress: false
dimFinishedEvents: true
- type: 'custom:mini-media-player'
entity: media_player.ps4_child
group: true
artwork: full-cover-fit
hide:
volume: true
controls: true
power: true
source: true
- type: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: vertical-stack
title: Today
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Played
icon: gamepad-variant
time_today: sensor.ps4_child_playing_game
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Watched
icon: youtube
time_today: sensor.ps4_child_playing_app
- type: vertical-stack
title: Today
cards:
- time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Games left
icon: gamepad-variant
max_today: input_datetime.ps4_child_game_time
time_today: sensor.ps4_child_playing_game
format: Time Left
- format: Time Left
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Cartoons left
icon: youtube
max_today: input_datetime.ps4_child_app_time
time_today: sensor.ps4_child_playing_app
- type: vertical-stack
title: This week
cards:
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Played
icon: gamepad-variant
time_today: sensor.ps4_child_weekly_game
- format: Time Elapsed
time_format: 1h 5m
type: 'custom:elapsed-time-card'
name: Cartoons
icon: youtube
time_today: sensor.ps4_child_weekly_app
- type: horizontal-stack
cards:
- type: history-graph
entities:
- entity: sensor.ps4_child_playing_game
name: Played
hours_to_show: 24
refresh_interval: 1
height: 120
- type: history-graph
entities:
- entity: sensor.ps4_child_playing_app
name: In total
- entity: sensor.ps4_child_netflix
name: Netflix
- entity: sensor.ps4_child_disney
name: Disney+
hours_to_show: 24
refresh_interval: 1
height: 200
...and it looks like this:
A hell off a long post 😅
There's a lot of things that could be done better, etc. but nevertheless, that should cover ~everything we have, related to this.
Forgot the events:
automations/events.yaml
- id: ps4_child_event_fired_PS4_child_TURN_ON
alias: PS4 child - Event Fired - Turn On
trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: PS4_child_TURN_ON
- platform: event
event_type: mobile_app_notification_action
event_data:
action: PS4_child_TURN_ON
action:
- service: switch.turn_on
entity_id: switch.shelly_childn_tv
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: Permission to play granted.
- service: notify.kirbo_milli_child_kaikki
data:
message: Permission to play granted
- service: rest_command.control_ps
data:
target: child
user: hurrdurr
action: power-on
extra: ""
- id: ps4_child_event_fired_PS4_child_PS4_child_DENIED
alias: PS4 child - Event Fired - Denied
trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: PS4_child_DENIED
- platform: event
event_type: mobile_app_notification_action
event_data:
action: PS4_child_DENIED
action:
- service: switch.turn_off
entity_id: switch.shelly_childn_tv
- service: script.turn_on
entity_id: script.child_tts
data:
variables:
message: Permission to play denied.
- service: notify.kirbo_milli_child_kaikki
data:
message: Permission to play denied
@littlbee may I close this issue?
Hello
could you share how you defined your sensor.ps4_playing_game sensor ? Seems you are using the same sensor for measuring different application usage, so I'm a bit confused.
Thanks !