Simple local "bell system" according to a calendar

Hey. I had a fairly simple task on one of the events I co-organized and had 2 days to figure a solution to it. I want to share it here as I consider it as a 80/20 solution and it wouldn’t be that easy without Home assistant.

Description

There were classes scheduled in 5 rooms (two rooms were somewhat connected). The goal was to set up a “bell system” where you would get a “ding” in each of these rooms two minutes before the class starts, when the class starts, two minutes before the class ends and when the class ends. The two-minute timers had a different sound than the start/end of the classes. It shouldn’t ding on breaks and there also were events that shouldn’t have the end bells.

The way how I did (I had a home assistant server running on the local network):

  1. installed Browser_mod
  2. uploaded two 20 sec sounds to the home assistant server under local media
  3. scrambled 5 old laptops and mobile phones around my house and friends
  4. installed chrome browser on these laptops and one iPhone and made them not go to sleep mode or switch off the screen, having them always on while plugged in. This is quite challenging - Android phones apparently cannot be made easily “never turn off screen” mode, and Macs also do switch off when the lid is closed (I might have miss some settings, the browser_mod simply sometimes disconnected)
  5. I logged in into home assistant (created a different account) for all these devices and registered them to home assistant browser mod (now the devices became available as media players)
  6. used the official Google Calendar integration for HA and connected a newly created calendar “Bell system”
  7. used the following automation to trigger the bells on all media players depending on the events in the calendar:
alias: Bell system
description: ""
trigger:
  - platform: calendar
    event: start
    offset: "-0:2:0"
    entity_id: calendar.hostacov_bell_system
    id: before_event_start
  - platform: calendar
    event: start
    offset: "0:0:0"
    entity_id: calendar.hostacov_bell_system
    id: event_start
  - platform: calendar
    event: end
    offset: "-0:2:0"
    entity_id: calendar.hostacov_bell_system
    id: before_end
  - platform: calendar
    event: end
    offset: "-0:0:0"
    entity_id: calendar.hostacov_bell_system
    id: event_end
condition:
  - condition: template
    value_template: "{{'break' not in (trigger.calendar_event.summary | lower)}}"
  - condition: template
    value_template: >-
      {{not ((trigger.trigger_id in ['event_end', 'before_end']) and ('no end'
      in (trigger.calendar_event.summary | lower)))}}
action:
  - if:
      - condition: or
        conditions:
          - condition: trigger
            id: before_event_start
          - condition: trigger
            id: before_end
    then:
      - service: media_player.play_media
        data:
          media_content_id: media-source://media_source/local/bowl-pre.mp3
          media_content_type: audio
        target:
          entity_id:
            - media_player.tetragon
            - media_player.fireplace
            - media_player.common
            - media_player.green_room
    else:
      - service: media_player.play_media
        data:
          media_content_id: media-source://media_source/local/bowl-end.mp3
          media_content_type: audio
        target:
          entity_id:
            - media_player.tetragon
            - media_player.fireplace
            - media_player.common
            - media_player.green_room
mode: single

All that was needed by now was just allowing users to give access to that google calendar so they could put events there by themselves via a very user-friendly UI. If they didn’t want bells at all, they have to put a word break in the name of the event, and if they don’t want the end bells they put in no end string in the event name.

I optionally connected Bluetooth speaker to some devices to make the sound nicer/better.

The ugly thing is that the browser_mod is rather unreliable (and possibly unmaintained?), as it will disconnect when the main server restarts (so you have to walk around all the devices and refresh the site again), it didn’t work on an older android phone at all (simply didn’t register the media_player for an unknown and somewhat undebuggable reason). I also had to ensure that the devices were on the local network, otherwise, the media players weren’t available.

Next time, I would very probably rather use something like Volumio - The Music Player or OSMC/kodi, but that sounds a bit more heavy weighted and likely unavailable on mobile phones (as opposed to a just browser). Update: It is actually very easy on Android as well, so Kodi is recommended approach to this IMHO.

1 Like

Nice idea!