Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
I2C based light with dimming
################################################################
## Packages / Dimmer Test
##
## @description I2C based light with dimming
## @component input_number, light, shell_command
## @license MIT
## @author Dale Higgs <@dale3h>
################################################################
################################################
## Customize
################################################
homeassistant:
customize:
input_number.dimmer_test_brightness:
hidden: true
################################################
## Input Number
################################################
input_number:
dimmer_test_brightness:
name: "Dimmer Test Brightness"
initial: 255
min: 1
max: 255
step: 1
################################################
## Light
################################################
light:
- platform: template
lights:
dimmer_test:
friendly_name: "Dimmer Test"
level_template: "{{ states('input_number.dimmer_test_brightness')|int }}"
turn_on:
- service: shell_command.dimmer_test
data_template:
previous: 0
brightness: "{{ states('input_number.dimmer_test_brightness')|int(255) }}"
turn_off:
- service: shell_command.dimmer_test
data_template:
brightness: 0
set_level:
- service: shell_command.dimmer_test
data_template:
brightness: "{{ brightness|int }}"
- service: input_number.set_value
data_template:
entity_id: input_number.dimmer_test_brightness
value: "{{ brightness|int }}"
################################################
## Shell Command
################################################
shell_command:
dimmer_test: >-
python3 /home/homeassistant/.homeassistant/python_scripts/rpi_i2c.py {{ (previous|default(states('input_number.dimmer_test_brightness')|int(255))|int * (100 / 255))|round }} {{ (brightness|int * (100 / 255))|round }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment