Workday Sensor Weirdness

Hi there,
I seem to be having an issue getting the workday sensor to work correctly(what I assume it’s intended to do).

I’m trying to set up an automation that has the workday binary sensor as a condition. (when the light switch is pushed and the light is on and it is a workday then turn off the light ). This is an working automation that breaks if I add the workday condition. By breaks I mean it doesn’t run at all.

What I have tried? Google, deleted a recreated the automation, changed the args for state and attribute(all choices on the dropdown), even set the conditions state to off, use UI to create automation, use yaml to create automation, validate configuration, and restarted home assistant and router many times tried all kinds of combos with this, created a custom binary_sensor.yaml ,even tried it with other automations, when i try to use it as a condition the automation stops working, tried using AND this didn’t work either. added sensor to Lovelace and checked the state in dev tools, it’s there and showing as ‘on’ state.

Info that might help:
Automation

alias: 'button turn off master light '
description: button turn on master light
trigger:
  - platform: device
    type: turned_off
    device_id: ***7
    entity_id: switch.three_way_switch_living_room_switch_2
    domain: switch
condition:
  - condition: device
    type: is_on
    device_id: ***8
    entity_id: light.master_als09l
    domain: light
  - condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'on'
    attribute: workdays
action:
  - type: turn_off
    device_id: ***8
    entity_id: light.master_als09l
    domain: light
mode: restart

binary_sensor.yaml



#workday sensor

  - platform: workday
    country: ZA
    workdays: [mon, tue, wed, thu, fri]
    excludes: [sat, sun, holiday]
    add_holidays:
      - '2020-02-24'
  

configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

#Include files here 
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
binary_sensor: !include binary_sensor.yaml

Anyway, I’m sure it’s something small that I’m not aware of perhaps? Any help and suggestions will be greatly appreciated! If you need further info please ask.

Thanks in advance for all the help!

Remove that from the condition. Workday sensor is ‚on‘, if current day is a workday.

Thanks, man awesome it is working now , knew it was something I was small, but why does this field attribute break it? and why does the UI put it in the yaml file if it breaks functionality? thanks, yeah I read the documentation and I understand how it meant to be used workday = true/on nonworkday=false/off.

As a new user, I can say Home Assistant is great but the documentation leaves much to be desired.

I partly agree, but you get used to it and the examples are great. So, in brief:

  - condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'on'
    attribute: workdays

This condition passes, if the attribute named ‘workdays’ on binary_sensor.workday_sensor is “on”. But that’s never the case, because states.binary_sensor.workday_sensor.attributes.workdays returns
an array of days of week (from the configuration). So, it’s never “on”

  - condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'on'

The condition passes, if the actual state (states.binary_sensor.workday_sensor.state) is ‘on’, which is the case if current day is a workday.

That’s a flaw in the UI editor. If you picked an (optional) attribute from the list in the UI, it gets added to the Yaml. Even if you clear the field in the UI manually later. You need to switch to YAML mode in that specific block and remove the field (and value) again. Then return to visual mode.