Shell Commands

Integration Key: shell

The Shell integration allows you to execute any shell command on a schedule and use the output as the state of a sensor. This is useful for passing metrics about the machine that room-assistant is running on or for integrating sensors that do not have native support.

The commands are run with the same user that room-assistant is running with, so make sure your permissions are setup accordingly.

Settings

NameTypeDefaultDescription
sensorsShell SensorsAn array of shell sensor definitions.
switchesShell SwitchesAn array of shell switch definitions.

Sensors

NameTypeDefaultDescription
nameStringFriendly name of this sensor.
commandStringShell command that should be executed.
regexStringRegex that is used for parsing the stdout output of the command, if configured. Otherwise the complete output is used as the state.
cronStringCron patternopen in new window describing the schedule that this command should be run with.
iconStringIcon that the sensor should be represented with in Home Assistant Core.
unitOfMeasurementStringUnit of measurement of the sensor state, leave empty if none.
deviceClassStringHome Assistant Core device classopen in new window to be used for this sensor.

Switches

NameTypeDefaultDescription
nameStringFriendly name of this switch.
onCommandStringShell command that should be executed when the switch is turned on.
offCommandStringShell command that should be executed when the switch is turned off.
iconStringIcon that the sensor should be represented with in Home Assistant Core.
Example Config
global:
  integrations:
    - shell
shell:
  sensors:
    - name: Kitchen Wifi Strength
      command: 'iwconfig wlan0 | grep -i quality'
      regex: 'Signal level=(-?[0-9]+) dBm'
      cron: '* * * * *'
      icon: mdi:wifi
      unitOfMeasurement: dBm
      deviceClass: signal_strength
  switches:
    - name: Onboard LED
      onCommand: 'echo mmc0 | sudo tee /sys/class/leds/led0/trigger'
      offCommand: 'echo none | sudo tee /sys/class/leds/led0/trigger && echo 1 | sudo tee /sys/class/leds/led0/brightness'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16