Files
ad_trident/apps/global/virtualsensors.yaml
T
2026-10-04 10:26:39 +02:00

122 lines
6.9 KiB
YAML

virtual_sensors:
module: virtualsensors
class: VirtualSensorsApp
priority: 10 # default priority app is 50, since most of them require sensors created by virtual sensors, it's important that virtual_sensors start first
default_values:
binary_sensor.is_tv_on: false
sensors:
binary_sensor.someone_home: person.maeva == 'home' or person.pierre == 'home' or (input_boolean.use_red_shelly_presence and binary_sensor.red_shelly_home)
binary_sensor.is_dark_outside: sun.sun == 'below_horizon'
# Rain commute: time windows are provided by Home Assistant binary sensors.
sensor.commut_rain_minutes_le_cres: sensor.next_rain_le_cres.minutes_until_rain
sensor.commut_rain_minutes_castelnau: sensor.next_rain_castelnau_le_lez.minutes_until_rain
sensor.commut_rain_intensity_le_cres: sensor.next_rain_le_cres.intensity
sensor.commut_rain_intensity_castelnau: sensor.next_rain_castelnau_le_lez.intensity
value_selector.commut_rain_minutes_until_rain:
values:
le_cres_first:
conditions: >-
sensor.commut_rain_minutes_le_cres != 'unknown' and
sensor.commut_rain_minutes_le_cres != 'unavailable' and
sensor.commut_rain_minutes_castelnau != 'unknown' and
sensor.commut_rain_minutes_castelnau != 'unavailable' and
sensor.commut_rain_minutes_le_cres <= sensor.commut_rain_minutes_castelnau
value: sensor.commut_rain_minutes_le_cres
le_cres_only:
conditions: sensor.commut_rain_minutes_le_cres != 'unknown' and sensor.commut_rain_minutes_le_cres != 'unavailable'
value: sensor.commut_rain_minutes_le_cres
castelnau_only:
conditions: sensor.commut_rain_minutes_castelnau != 'unknown' and sensor.commut_rain_minutes_castelnau != 'unavailable'
value: sensor.commut_rain_minutes_castelnau
unknown: true
value_selector.commut_rain_intensity:
values:
Pluie forte: sensor.commut_rain_intensity_le_cres == 'Pluie forte' or sensor.commut_rain_intensity_castelnau == 'Pluie forte'
Pluie modérée: sensor.commut_rain_intensity_le_cres == 'Pluie modérée' or sensor.commut_rain_intensity_castelnau == 'Pluie modérée'
Pluie faible: sensor.commut_rain_intensity_le_cres == 'Pluie faible' or sensor.commut_rain_intensity_castelnau == 'Pluie faible'
Temps sec: sensor.commut_rain_intensity_le_cres == 'Temps sec' and sensor.commut_rain_intensity_castelnau == 'Temps sec'
unknown: true
binary_sensor.commut_rain:
conditions: >-
binary_sensor.pierre_workday and
((person.pierre == 'home' and binary_sensor.morning_commut_time) or
(person.pierre != 'home' and person.pierre != 'unknown' and person.pierre != 'unavailable' and binary_sensor.evening_commut_time)) and
((sensor.next_rain_le_cres != 'unknown' and sensor.next_rain_le_cres != 'unavailable') or
(sensor.next_rain_castelnau_le_lez != 'unknown' and sensor.next_rain_castelnau_le_lez != 'unavailable'))
sensor_attributes:
minutes_until_rain_le_cres: sensor.commut_rain_minutes_le_cres
minutes_until_rain_castelnau: sensor.commut_rain_minutes_castelnau
minutes_until_rain: sensor.commut_rain_minutes_until_rain
intensity: sensor.commut_rain_intensity
event_sensor.red_shelly_home:
retain_time: 120
activation_events:
signal_strenght:
event_name: state_changed
event_data:
entity_id: sensor.shelly_button_red_signal_strength
# living room sensors
value_selector.living_room_ambiance_light:
values:
0:
- not binary_sensor.living_room_occupancy
- binary_sensor.projector_on and not binary_sensor.is_vertex2_content_idle
- binary_sensor.is_tv_on
- light.living_room
- sensor.mezzanine_motion_light_level > 15
- binary_sensor.is_living_room_sleeping
1:
- binary_sensor.is_everybody_sleeping
- binary_sensor.projector_on
2: true
# home cinema sensors
binary_sensor.projector_on: switch.living_room_projector_plug and sensor.living_room_projector_plug_power > 50
continuous_condition.projector_off_for_a_while:
time: 90
default_value: on
conditions: not binary_sensor.projector_on
# is_apple_tv_on is not reliable as the the apple tv integration sometimes return "paused" when it's actually off,
# you should use is_using_apple_tv instead for most automation
binary_sensor.is_apple_tv_on: media_player.apple_tv != 'off' and media_player.apple_tv != 'idle'
binary_sensor.is_xbox_on: binary_sensor.yetanotherpedro #media_player.xbox != 'off' and media_player.xbox != 'unavailable'
binary_sensor.is_playstation_on: switch.ps5_136_power
sensor.vertex2_input_selected_icon: sensor.vertex2_input_selected.icon
retain_condition.vertex2_has_input_signal:
retain_time: 10
conditions:
trigger_conditions: (sensor.vertex2_video_signal and sensor.vertex2_video_signal != 'no signal') or sensor.vertex2_audio_signal
disable_conditions: binary_sensor.vertex2_unreachable
sensor_attributes:
icon: sensor.vertex2_input_selected_icon
binary_sensor.is_using_apple_tv: binary_sensor.is_apple_tv_on and binary_sensor.vertex2_has_input_signal and sensor.vertex2_input_selected == 'AppleTV'
binary_sensor.is_using_xbox: binary_sensor.is_xbox_on and binary_sensor.vertex2_has_input_signal and sensor.vertex2_input_selected == 'Xbox'
binary_sensor.is_using_playstation: binary_sensor.is_playstation_on and binary_sensor.vertex2_has_input_signal and sensor.vertex2_input_selected == 'Playstation'
continuous_condition.is_vertex2_content_idle:
time: 5
conditions:
trigger_conditions:
- binary_sensor.is_using_apple_tv and (media_player.apple_tv == 'paused' or media_player.apple_tv == 'idle' or media_player.apple_tv == 'standby')
# - binary_sensor.is_using_playstation and sensor.ps5_136_activity == 'idle'
# - binary_sensor.is_using_xbox and not binary_sensor.yetanotherpedro_in_game
#p1p sensors
binary_sensor.p1p_is_printing:
trigger_conditions: sensor.garage_p1p_etat_de_l_impression != 'idle' and sensor.garage_p1p_etat_de_l_impression != 'finish' and sensor.garage_p1p_etat_de_l_impression != 'idle' and sensor.garage_p1p_etat_de_l_impression != 'offline'
disable_conditions: sensor.garage_p1p_etat_de_l_impression == 'offline' and switch.garage_p1p_plug
blocking_conditions: not switch.garage_p1p_plug
binary_sensor.p1p_is_active:
trigger_conditions:
- binary_sensor.p1p_is_printing
- fan.garage_p1p_ventilateur_de_la_chambre or fan.garage_p1p_ventilateur_de_refroidissement
- sensor.garage_p1p_temperature_cible_de_la_buse > 0 or sensor.garage_p1p_temperature_cible_du_lit > 0
blocking_conditions: not switch.garage_p1p_plug