Have been struggling with this problem for days and no matter what I try I am unable to get there. I have a home assistant input number that I’d like to use in delay functions. But it requires a either a float or a string where I’d like to use an integer.
I want to use it to set the delay time in minutes.
I obtain the value from home assistant as follows:
sensor:
- platform: homeassistant
id: max_run_time_minutes
name: "Max Run Time - All Zones"
entity_id: input_number.irrigation_max_duration
I want to use it with the delay function of this block:
ESP Home complains that minutes expects a float. I tried to set up a global float but that doesn’t work either.
I have managed to use a substitution to set the delay time:
substitutions:
# Set Max Run Time Here: =============================#
max_run_time: "10min"
# Sets delay between switch turn on and switch turn off
#======================================================#
But I can’t figure out how to get that back to home assistant.
Although you may be better off converting into a variable, I can’t tell if the above format will work. I had to do a lot of this for the display component.
Thanks, I sure would like to assign it to a variable if I can figure out how. My understanding is that delay requires a string. I have used a substitution to set the delay…
OK, so it is not possible to define an initial value as a number only as a string? Even though, as per the example on the ESP Home site, it has been defined as an integer.
# Example configuration entry
globals:
- id: my_global_int
type: int
restore_value: no
initial_value: '0'
This has been something I have wanted to fix for a while now.
I have an input number in home assistant that sets a max run time in minutes. I can see in the esphome log that the value changes as the home assistant input number changes.
The value is read here:
sensor:
- platform: homeassistant
id: max_run_time_minutes
name: "Max Run Time - All Zones"
entity_id: input_number.irrigation_max_duration
icon: mdi:av-timer
accuracy_decimals: 0
on_value:
- globals.set:
id: max_time2run
value: !lambda 'return id(max_run_time_minutes).state * 60000;'
What I am struggling with is returning that value back to home assistant as a confirmation the value has been set. Not sure if I need another sensor to bring that value back to home assistant or what sort of sensor it should be.
I am trying a text sensor:
text_sensor:
- platform: template
name: "Max run time set"
icon: mdi:timer
lambda: return {id(max_run_time_minutes)};
The code validates correctly but won’t compile. Here is the error I am getting"
config/esphome/switch_back_4ch.yaml: In lambda function:
/config/esphome/switch_back_4ch.yaml:266:35: error: could not convert '{max_run_time_minutes}' from '<brace-enclosed initializer list>' to 'esphome::optional<std::__cxx11::basic_string<char> >'
266 |
| ^
| |
| <brace-enclosed initializer list>
*** [.pioenvs/switch-irrigation-4ch/src/main.cpp.o] Error 1