Indicating day of the week with lights?

Hello,

i would like to use a wemos d1 mini in combination with a ws2812b led strip in ESPhome to indicate what day of the month it is.

This would mean 1 set of 7 lights to indicate monday-sunday. One set of 31 lights for the days, and one set of lights indicating the month.

I have 2 sensors:

  - sensors:
      dayoftheweek:
        value_template: "{{ ['Mo','Tu','We','Th','Fr','Sa','Su'][now().weekday()] }}"
        entity_id: sensor.day
 
  - sensors:
      months:
        value_template: "{{ ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Okt','Nov','Dec'][now().month-1] }}"
        entity_id: sensor.month

im missing 1 more for the day, which i dont know how to make yet.

So my overall question would be how would i write the code part in Esphome, and how to put this in a automation in HA?
Any help would be appreciated.

What sort of lights are you using? You’ll need addressables as an esp is not going to have enough GPIO’s to so 7+31+12 = 50 lights.

its a ws2812b led strip. I think you can use 1 gpio for all, as you can turn the ledstrip into segments.

light:
  - platform: neopixelbus
    id: all_leds
    name: "All LEDs"
    pin: GPIO1
    variant: WS2812X
    type: GRB
    method: ESP8266_UART0
    num_leds: 36
    restore_mode: ALWAYS_OFF
    
  - platform: partition
    id: segment_1
    name: "Segment 1"
    segments:
      - id: all_leds
        from: 0
        to: 5
    
  - platform: partition
    id: segment_2
    name: "Segment 2"
    segments:
      - id: all_leds
        from: 6
        to: 11

Basically I’m interested in this too, I’m making mqtt json lights for holidays with esphome an HA.

I think you could make effect for each day and then change it with HA automation?

And yes, you need just 1 gpio.

i need 1 automation for mon-sun which i think i can use the day of the week sensor for.
the month sensor is the same.

they day is the only one that i dont know.

Im also gonna try to integrate google calander in it for appointments, birthdays etc.

Code Sofar

esphome:
  name: calendar

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "1Gbf4McbEAZhvQIzJ28Kqoa29z31fXX481u3/nsn6p4="

ota:
  password: "1396b5c86ab25337987a9ea01f6085ca"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Calendar Fallback Hotspot"
    password: "PnsaOuShCCHS"

captive_portal:

light:
  - platform: neopixelbus
    id: calendar_lights
    name: "Calendar Lights"
    pin: GPIO1
    variant: WS2812X
    type: GRB
    method: ESP8266_UART0
    num_leds: 50
    restore_mode: ALWAYS_OFF

  - platform: partition
    id: segment_week_1
    name: "Monday Light"
    segments:
      - id: calendar_lights
        from: 0
        to: 0

  - platform: partition
    id: segment_week_2
    name: "Tuesday Light"
    segments:
      - id: calendar_lights
        from: 1
        to: 1

  - platform: partition
    id: segment_week_3
    name: "Wednesday Light"
    segments:
      - id: calendar_lights
        from: 2
        to: 2

  - platform: partition
    id: segment_week_4
    name: "Thursday Light"
    segments:
      - id: calendar_lights
        from: 3
        to: 3

  - platform: partition
    id: segment_week_5
    name: "Friday Light"
    segments:
      - id: calendar_lights
        from: 4
        to: 4

  - platform: partition
    id: segment_week_6
    name: "Saturday Light"
    segments:
      - id: calendar_lights
        from: 5
        to: 5

  - platform: partition
    id: segment_week_7
    name: "Sunday Light"
    segments:
      - id: calendar_lights
        from: 6
        to: 6

  - platform: partition
    id: segment_month_1
    name: "January Light"
    segments:
      - id: calendar_lights
        from: 7
        to: 7

  - platform: partition
    id: segment_month_2
    name: "February Light"
    segments:
      - id: calendar_lights
        from: 8
        to: 8

  - platform: partition
    id: segment_month_3
    name: "March Light"
    segments:
      - id: calendar_lights
        from: 9
        to: 9

  - platform: partition
    id: segment_month_4
    name: "April Light"
    segments:
      - id: calendar_lights
        from: 10
        to: 10

  - platform: partition
    id: segment_month_5
    name: "May Light"
    segments:
      - id: calendar_lights
        from: 11
        to: 11

  - platform: partition
    id: segment_month_6
    name: "June Light"
    segments:
      - id: calendar_lights
        from: 12
        to: 12
    
  - platform: partition
    id: segment_month_7
    name: "July Light"
    segments:
      - id: calendar_lights
        from: 13
        to: 13

  - platform: partition
    id: segment_month_8
    name: "August Light"
    segments:
      - id: calendar_lights
        from: 14
        to: 14

  - platform: partition
    id: segment_month_9
    name: "September Light"
    segments:
      - id: calendar_lights
        from: 15
        to: 15

  - platform: partition
    id: segment_month_10
    name: "October Light"
    segments:
      - id: calendar_lights
        from: 16
        to: 16

  - platform: partition
    id: segment_month_11
    name: "November Light"
    segments:
      - id: calendar_lights
        from: 17
        to: 17

  - platform: partition
    id: segment_month_12
    name: "December Light"
    segments:
      - id: calendar_lights
        from: 18
        to: 18

got a sensor for the day:

  - sensors:
      dayofmonth:
        value_template: "{{ now().day}}"

does anyone know how to remove the st, th, rd, from the code?
i prefer to have just a number.

Try replacing your 4 lines with this:
{{now().day}}

1 Like

Thanks that was easy!

i finished the code but it is not working. It works up to number 15 only.
Could it be that the d1 runs out of memory?

esphome:
  name: calendar

esp8266:
  board: d1_mini_pro

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "1396b5c86ab25337987a9ea01f6085ca"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Calendar Fallback Hotspot"
    password: "PnsaOuShCCHS"

captive_portal:

light:
  - platform: neopixelbus
    id: calendar_lights
    name: "Calendar Lights"
    pin: GPIO1
    variant: WS2812X
    type: GRB
    method: ESP8266_UART0
    num_leds: 50
    restore_mode: ALWAYS_OFF

  - platform: partition
    id: segment_week_1
    name: "Monday Light"
    segments:
      - id: calendar_lights
        from: 0
        to: 0

  - platform: partition
    id: segment_week_2
    name: "Tuesday Light"
    segments:
      - id: calendar_lights
        from: 1
        to: 1

  - platform: partition
    id: segment_week_3
    name: "Wednesday Light"
    segments:
      - id: calendar_lights
        from: 2
        to: 2

  - platform: partition
    id: segment_week_4
    name: "Thursday Light"
    segments:
      - id: calendar_lights
        from: 3
        to: 3

  - platform: partition
    id: segment_week_5
    name: "Friday Light"
    segments:
      - id: calendar_lights
        from: 4
        to: 4

  - platform: partition
    id: segment_week_6
    name: "Saturday Light"
    segments:
      - id: calendar_lights
        from: 5
        to: 5

  - platform: partition
    id: segment_week_7
    name: "Sunday Light"
    segments:
      - id: calendar_lights
        from: 6
        to: 6

  - platform: partition
    id: segment_month_1
    name: "January Light"
    segments:
      - id: calendar_lights
        from: 7
        to: 7

  - platform: partition
    id: segment_month_2
    name: "February Light"
    segments:
      - id: calendar_lights
        from: 8
        to: 8

  - platform: partition
    id: segment_month_3
    name: "March Light"
    segments:
      - id: calendar_lights
        from: 9
        to: 9

  - platform: partition
    id: segment_month_4
    name: "April Light"
    segments:
      - id: calendar_lights
        from: 10
        to: 10

  - platform: partition
    id: segment_month_5
    name: "May Light"
    segments:
      - id: calendar_lights
        from: 11
        to: 11

  - platform: partition
    id: segment_month_6
    name: "June Light"
    segments:
      - id: calendar_lights
        from: 12
        to: 12
    
  - platform: partition
    id: segment_month_7
    name: "July Light"
    segments:
      - id: calendar_lights
        from: 13
        to: 13

  - platform: partition
    id: segment_month_8
    name: "August Light"
    segments:
      - id: calendar_lights
        from: 14
        to: 14

  - platform: partition
    id: segment_month_9
    name: "September Light"
    segments:
      - id: calendar_lights
        from: 15
        to: 15

  - platform: partition
    id: segment_month_10
    name: "October Light"
    segments:
      - id: calendar_lights
        from: 16
        to: 16

  - platform: partition
    id: segment_month_11
    name: "November Light"
    segments:
      - id: calendar_lights
        from: 17
        to: 17

  - platform: partition
    id: segment_month_12
    name: "December Light"
    segments:
      - id: calendar_lights
        from: 18
        to: 18

  - platform: partition
    id: segment_day_1
    name: "Number 1"
    segments:
      - id: calendar_lights
        from: 19
        to: 19

  - platform: partition
    id: segment_day_2
    name: "Number 2"
    segments:
      - id: calendar_lights
        from: 20
        to: 20

  - platform: partition
    id: segment_day_3
    name: "Number 3"
    segments:
      - id: calendar_lights
        from: 21
        to: 21

  - platform: partition
    id: segment_day_4
    name: "Number 4"
    segments:
      - id: calendar_lights
        from: 22
        to: 22

  - platform: partition
    id: segment_day_5
    name: "Number 5"
    segments:
      - id: calendar_lights
        from: 23
        to: 23

  - platform: partition
    id: segment_day_6
    name: "Number 6"
    segments:
      - id: calendar_lights
        from: 24
        to: 24

  - platform: partition
    id: segment_day_7
    name: "Number 7"
    segments:
      - id: calendar_lights
        from: 25
        to: 25

  - platform: partition
    id: segment_day_8
    name: "Number 8"
    segments:
      - id: calendar_lights
        from: 26
        to: 26

  - platform: partition
    id: segment_day_9
    name: "Number 9"
    segments:
      - id: calendar_lights
        from: 27
        to: 27

  - platform: partition
    id: segment_day_10
    name: "Number 10"
    segments:
      - id: calendar_lights
        from: 28
        to: 28

  - platform: partition
    id: segment_day_15
    name: "Number 15"
    segments:
      - id: calendar_lights
        from: 33
        to: 33

  - platform: partition
    id: segment_day_16
    name: "Number 16"
    segments:
      - id: calendar_lights
        from: 34
        to: 34

  - platform: partition
    id: segment_day_17
    name: "Number 17"
    segments:
      - id: calendar_lights
        from: 35
        to: 35

  - platform: partition
    id: segment_day_18
    name: "Number 18"
    segments:
      - id: calendar_lights
        from: 36
        to: 36

  - platform: partition
    id: segment_day_19
    name: "Number 19"
    segments:
      - id: calendar_lights
        from: 37
        to: 37

  - platform: partition
    id: segment_day_20
    name: "Number 20"
    segments:
      - id: calendar_lights
        from: 38
        to: 38

  - platform: partition
    id: segment_day_21
    name: "Number 21"
    segments:
      - id: calendar_lights
        from: 39
        to: 39

  - platform: partition
    id: segment_day_22
    name: "Number 22"
    segments:
      - id: calendar_lights
        from: 40
        to: 40

  - platform: partition
    id: segment_day_23
    name: "Number 23"
    segments:
      - id: calendar_lights
        from: 41
        to: 41

  - platform: partition
    id: segment_day_24
    name: "Number 24"
    segments:
      - id: calendar_lights
        from: 42
        to: 42

  - platform: partition
    id: segment_day_25
    name: "Number 25"
    segments:
      - id: calendar_lights
        from: 43
        to: 43

  - platform: partition
    id: segment_day_26
    name: "Number 26"
    segments:
      - id: calendar_lights
        from: 44
        to: 44

  - platform: partition
    id: segment_day_27
    name: "Number 27"
    segments:
      - id: calendar_lights
        from: 45
        to: 45

  - platform: partition
    id: segment_day_28
    name: "Number 28"
    segments:
      - id: calendar_lights
        from: 46
        to: 46

  - platform: partition
    id: segment_day_29
    name: "Number 29"
    segments:
      - id: calendar_lights
        from: 47
        to: 47

  - platform: partition
    id: segment_day_30
    name: "Number 30"
    segments:
      - id: calendar_lights
        from: 48
        to: 48

  - platform: partition
    id: segment_day_31
    name: "Number 31"
    segments:
      - id: calendar_lights
        from: 49
        to: 49

it says:

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v0006c8d0
~ld

How are you testing?

I edit the sketch and add 1 more “partition number” untill it stops working. I plug it in a wall socket after to make sure its not a power issue.

So is that a compile error?

it uploads fine, after the reboot of the chip that is what shows in the log