Webex Status Light
This note provides the specific details needed to tie your Webex status into a Do Not Disturb light via Home Assistant.
First, you need to edit your HA configuration.yaml file to refer to two other files. One for command line sensor configurations, and the other for automations.
Place these two lines in configuration.yaml if they's don't already exist.
command_line: !include command_line.yaml
automation: !include automations.yaml
Next, you'll need to open or create the file named command_line,yaml and enter the following lines to create the sensor which will reach out to the Webex API and check your status. This sensor configuration requires two pieces of information, one is a long-lived Bearer token for access to the Webex API. The easiest way to obtain one of these is to create an account at https://developer.webex.com and register a Webex bot. Registering a bot will give a token that you can use for this and any other access you may need to the Webex API. Make sure that you take note of this token when it is shown and keep it in a safe place. It will only be shown once and must be regenerated if forgotten.
Place the following in command_line.yaml. If you change the name of this sensor, you'll also need to change the name in all places where it is referenced within the automations.yaml file in the next step.
command_line:
- sensor:
name: Webex Status Curl
command: "curl -H 'Authorization:Bearer <long-lived token>' https://webexapis.com/v1/people/people?email=<your personemail IDaddress>"
# Since the response is JSON, we can parse out the Status key
value_template: "{{ value_json.status }}"
scan_interval: 10
Place the following in automations.yamlyaml. The id in the first line can be any number you choose as long as it is unique within your HA configuration. Each potential status returned by Webex is listed here as a separate condition. You can change the service command for each status/condition to turn the light on or off for that status based on your preference.
-
id: '1690190769903'
alias: Webex Teams DND Update
description: ''
trigger:
- platform: state
entity_id:
- sensor.webex_status_curl
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: sensor.webex_status_curl
state: active
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.brian_dnd_light
- conditions:
- condition: state
entity_id: sensor.webex_status_curl
state: call
sequence:
- service: light.turn_on
data: {}
target:
entity_id: light.brian_dnd_light
- conditions:
- condition: state
entity_id: sensor.webex_status_curl
state: DoNotDisturb
sequence:
- service: light.turn_on
data: {}
target:
entity_id: light.brian_dnd_light
- conditions:
- condition: state
entity_id: sensor.webex_status_curl
state: inactive
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.brian_dnd_light
- conditions:
- condition: state
entity_id: sensor.webex_status_curl
state: meeting
sequence:
- service: light.turn_on
data: {}
target:
entity_id: light.brian_dnd_light
- conditions:
- condition: state
entity_id: sensor.webex_status_curl
state: OutOfOffice
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.brian_dnd_light
- conditions:
- condition: state
entity_id: sensor.webex_status_curl
state: pending
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.brian_dnd_light
- conditions:
- condition: state
entity_id: sensor.webex_status_curl
state: presenting
sequence:
- service: light.turn_on
data: {}
target:
entity_id: light.brian_dnd_light
- conditions:
- condition: state
entity_id: sensor.webex_status_curl
state: unknown
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.brian_dnd_light
default:
- service: light.turn_on
data: {}
target:
entity_id: light.brian_dnd_light
mode: single
Finally, after all of these files have been edited and saved, you'll want to restart your HA instance.
Now, you'll have an automation within Home Assistant that will toggle your DND light based on your Webex Status.
In this example, I already had a light entity named brian_dnd_light, so I didn't go into detail on how to create that. It is simply a smart bulb that I've tied into HA.