WFH Automation Ideas

This is a collection of automations that help me when I Work From Home on my desktop computer.

I have a dual boot system and most of the automations I mention work on both. For windows I am using HASS.Agent and on Linux I am using LNXLink.


Pause media playback when I am on the phone

When my phone is ringing or I am in a call, the media will be paused. This works on any application that I might be using like messenger, viber, etc…

Yaml Configuration
alias: Incoming call billy
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.redmi_note_8_pro_audio_mode
    to: ringing
  - platform: state
    entity_id:
      - sensor.redmi_note_8_pro_audio_mode
    to: in_call
  - platform: state
    entity_id:
      - sensor.redmi_note_8_pro_audio_mode
    to: in_communication
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: media_player.desktop_windows
        state: playing
      - condition: state
        entity_id: media_player.desktop_linux
        state: playing
action:
  - service: media_player.media_pause
    data: {}
    target:
      entity_id:
        - media_player.desktop_windows
        - media_player.desktop_linux
mode: single

Web Camera turns on Light

When I need to use the web camera, the light at my room turns on automatically so that people can see me better.

Yaml Configuration
alias: Webcam started
description: ""
trigger:
  - type: turned_on
    platform: device
    device_id: c5538068d8ae2f59ea0a46d9953b03ae
    entity_id: binary_sensor.desktop_linux_camera_used
    domain: binary_sensor
  - type: turned_on
    platform: device
    device_id: ac5aa697b615f40563be49834acc3a88
    entity_id: binary_sensor.desktop_windows_webcamactive
    domain: binary_sensor
condition: []
action:
  - service: scene.turn_on
    target:
      entity_id: scene.bright
    metadata: {}
  - wait_for_trigger:
      - type: turned_off
        platform: device
        device_id: c5538068d8ae2f59ea0a46d9953b03ae
        entity_id: binary_sensor.desktop_linux_camera_used
        domain: binary_sensor
      - type: turned_off
        platform: device
        device_id: ac5aa697b615f40563be49834acc3a88
        entity_id: binary_sensor.desktop_windows_webcamactive
        domain: binary_sensor
  - type: turn_off
    device_id: f94669e2f90611ea9467bb51f6786486
    entity_id: light.myroom
    domain: light
mode: single

Turn On/Off PC speakers

My Logitech speakers can be controlled via infrared, so when my PC turns on or off, a power command is sent through Broadlink RM Mini 3 remote.

Yaml Configuration
alias: MyPC state change
description: "Turns on or off the speakers of my 🖥 "
trigger:
  - platform: state
    entity_id: switch.my_pc
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: switch.my_pc
            state: "on"
        sequence:
          - service: media_player.turn_on
            data: {}
            target:
              entity_id: media_player.logitech
    default:
      - service: media_player.turn_off
        data: {}
        target:
          entity_id: media_player.logitech
mode: single

Turn off AC when door is opened

When I open my door for more than 10 seconds and the Air Conditioner is ON, it will automatically turn off.

Yaml Configuration
alias: MyRoomAC - TurnOff
trigger:
  - platform: state
    entity_id:
      - binary_sensor.billydoor_contact
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 10
condition:
  - condition: not
    conditions:
      - condition: state
        entity_id: climate.inventor_ac
        state: "off"
      - condition: state
        entity_id: climate.inventor_ac
        state: unavailable
action:
  - service: climate.turn_off
    data: {}
    target:
      entity_id:
        - climate.inventor_ac
mode: single

Notify on Hikvision Line Crossing event

My hikvision camera can recognize when someone has crossed a line that I’ve configured on the camera, so I get a notification on my desktop when this happens.

Yaml Configuration
alias: Hikvision - Linecrossing
trigger:
  - platform: state
    to: "on"
    entity_id:
      - binary_sensor.line_crossing
action:
  - service: camera.snapshot
    data:
      entity_id: camera.out_person
      filename: /config/www/hikvision.jpg
  - service: mqtt.publish
    data:
      topic: lnxlink/desktop-linux/commands/notify
      retain: false
      qos: 0
      payload_template: >-
        { "title": "Camera Hikvision", 
          "message": "Line crossing", 
          "iconUrl": "https://homeassistant.local/local/hikvision.jpg" }
  - service: notify.desktop_windows
    data:
      title: Camera Hikvision
      message: Line crossing
      data:
        image: >-
          https://homeassistant.local/local/hikvision.jpg
mode: single

3 Likes

These great ideas, thanks a lot! I also work from home, and will probably be using all four.

Plus, I was on the prowl for a HASS.agent-like piece of software that works on Linux, and hadn’t heard of LNXLink. Looks positively awesome!

Some will only work with android phone.