home-assistant.io/source/_components/binary_sensor.workday.markdown

2.9 KiB

layout title description date sidebar comments sharing footer logo ha_category ha_iot_class ha_release ha_qa_scale
page Workday Binary Sensor Steps to configure the binary workday sensor. 2017-03-13 21:30 true false true true home-assistant.png Utility Local Polling 0.41 internal

The workday binary sensor indicates, whether the current day is a workday or not. It allows specifying, which days of the week counts as workdays and also uses the python module holidays to incorporate information about region-specific public holidays.

{% linkable_title Configuration %}

Check the country list for available province.

To enable the workday sensor in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
binary_sensor:
  - platform: workday
    country: DE
    workdays: [mon, wed, fri]

{% configuration %} name: description: A name for this sensor. required: false type: string default: Workday Sensor country: description: > Country code according to holidays notation. required: true type: string province: description: > Province code according to holidays notation. required: false type: string workdays: description: List of workdays. required: false type: list default: "[mon, tue, wed, thu, fri]" excludes: description: List of workday excludes. required: false type: list default: "[sat, sun, holiday]" days_offset: description: Set days offset. required: false type: integer default: 0 {% endconfiguration %}

Days are specified as follows: mon, tue, wed, thu, fri, sat, sun. The keyword holiday is used for public holidays identified by the holidays module.

If you use the sensor for Norway (`NO`) you need to wrap `NO` in quotes or write the name in full. Otherwise the value is evaluated as `false`. If you use the sensor for Canada (`CA`) with Ontario (`ON`) as `province:` then you need to wrap `ON` in quotes. Otherwise the value is evaluated as `true` (check the YAML documentation for further details) and the sensor will not work.

{% linkable_title Automation example %}

Example usage for automation:

automation:
  alias: Turn on heater on workdays
  trigger:
    platform: time
    at: '08:00:00'
  condition:
    condition: state
    entity_id: 'binary_sensor.workday_sensor'
    state: 'on'
  action:
    service: switch.turn_on
    entity_id: switch.heater

Please remember that [as explained here][devices] you can only have a single `automation:` entry. Add the automation to your existing automations.