it did work, it’s just that your input number didn’t like having -39 assigned to it (0 to 256 range) not sure why I did the 256 now, could get away with 255
No, it just displays 123, which isn’t the actual value the dimmer is currently at, and changing this through the interface doesn’t change the levels and the value jumps back to 123
Monitor the number, it ‘should’ basically change every 80 seconds and go to 30 at 22:00 and jump to 0 and stay that way till 12:00 tomorrow jump to 30, ramp up, ramp down, rinse and repeat.
Check you don’t have this light anywhere else in you automations
Edit : There is a problem with brightnes: vs brightness_pct: (No Idea Why) Please go down to Post 95 for the workaround
I’m doing some experiments.
As an aside : @jwelter if you look at the entities created you will see that the code is based on useage of an editor that reads your whole configuration for autocomplete ability (like VSC) so my file would be called fishtank01.yaml
if I ever need to change the config for in_fishtank01_brightness_level I know I can find it in the fishtank01 file
Also when I’m typing and I want to use an entity, I start typing “inp” and options come up for input_boolean, input_number, input_select etc. I just click the one I want
hit “.” and all the input_numbers (in this case) come up. As I type the list is narrowed.
the ‘in_’ is just for easy recognition in entities lists (and it also helps in scanning through lists as alphabetically I will know where to find them), the next bit is the package, then what I’m using it for.
It makes coding a LOT faster.
@bedfellow so, I don’t actually use brightness, I use brightness_pct and when I cenvert the package to brightness_pct it works (not been through a full day yet though.
Here is my ‘modified’ package I’m testing with : -
It seems to be a tiny syntax discrepancy which I can’t find. hopefully @anon43302295 , @123 , @finity or @pnbruckner could cast an eye over the two and point out exactly where I have f****d up
Sorry about this, I thought the two were more of less interchangeable. If necessary I can rewrite this again using pct and reducing your processor load.
Okay, I found a thread with a solution to brightness: using a template by pnbruckner.
I remeber reading that ‘some’ devices are picky about specific indentation and don’t seem to follow normal rules, as the above shows.
I changed tthe syntax accordingly but still no joy.
I’ve given up
It does work for pct so I’ve modified the package for that.
Using 0 = off, 11 = minimum brightness, 100 = maximum, then over 5hrs (18,000 seconds) that’s a step every 202.247 (and some change). So I set the update to 101 (more than twice the required frequency but still a saving on the previous).
As the entity definitions have changed, it will require a restart
input_boolean:
ib_fishtank01_brightness_overide:
name: Brightness Overide
icon: mdi:arrow-collapse-up
input_number:
in_fishtank01_brightness_level:
name: Brightness (percent)
initial: 0
min: 0
max: 100
step: 1
mode: box
icon: mdi:arrow-expand-vertical
automation:
- alias: au_fishtank01_brightness_overide_on
trigger:
- platform: state
entity_id: input_boolean.ib_fishtank01_brightness_overide
from: 'off'
to: 'on'
action:
- service: script.sc_fishtank01_overide_timer
- alias: au_fishtank01_brightness_overide_off
trigger:
- platform: state
entity_id: input_boolean.ib_fishtank01_brightness_overide
from: 'on'
to: 'off'
action:
- service: script.turn_off
entity_id: script.sc_fishtank01_overide_timer
- service: script.sc_fishtank01_overide_timer
- alias: au_fishtank01_adjust_brightness
trigger:
- platform: state
entity_id: input_number.in_fishtank01_brightness_level
- platform: state
entity_id: input_boolean.ib_fishtank01_brightness_overide
- platform: time_pattern
seconds: '/101'
action:
- service: script.sc_fishtank01_calc_level
- delay: '00:00:01'
- service: light.turn_on
# entity_id: light.fishtank01_level
entity_id: light.fibdim2_lgl1_level
data_template:
brightness_pct: "{{ states('input_number.in_fishtank01_brightness_level') }}"
transition: 5
script:
sc_fishtank01_overide_timer:
alias: FT Overide Timer Script
sequence:
- delay: "00:01:00"
- service: input_boolean.turn_off
entity_id: input_boolean.ib_fishtank01_brightness_overide
sc_fishtank01_calc_level:
alias: Fish Tank 01 Calc Brightness
sequence:
- service: input_number.set_value
data_template:
entity_id: input_number.in_fishtank01_brightness_level
value: >
{% set ovrd = is_state('input_boolean.ib_fishtank01_brightness_overide', 'on') %}
{% set tnow = as_timestamp(now()) %}
{% set date = now().strftime('%Y-%m-%d ') %}
{% set frm12 = tnow - as_timestamp(date ~ '12:00') %}
{% set frm17 = tnow - as_timestamp(date ~ '17:00') %}
{% set frm22 = tnow - as_timestamp(date ~ '22:00') %}
{% set cnt = frm22 < 0 <= frm12 %}
{% set rise = cnt and frm17 < 0 %}
{% set fall = cnt and frm17 >= 0 %}
{% set outp = 0.0 %}
{% if ovrd %}
{% set outp = 100 %}
{% elif rise %}
{% set outp = frm12 / 202.247 + 11 %}
{% elif fall %}
{% set outp = 100 - (frm17 / 202.247) %}
{% else %}
{% set outp = 0 %}
{% endif %}
{{ (outp + 0.5) | int }}
Again the light used is a test lamp so you will have to replace that with “your light”
PLEASE ensure you delete (or at least comment out all other instances of turn on/off etc of your light entity, as I said before this should do the lot.
I’ll await someone a ‘LOT’ wiser than I (sets the bar pretty low) to explain what’s going on with brightness vs brightness_pct
I recently had to do the same thing for a powerhead in my aquarium, I wanted to ramp up/down the speed over an hour however it wouldnt work using the transition command. I ended up using the repeat command to increase the percentage every x minutes.
So in your case since you want it to ramp up 88% over 18000 seconds you would need to increase the light 1% every 204 seconds (3 min & 24 seconds). So try the following: