Hi,
I’m quite new to home assistant so bare with me if i get some terminology incorrect.
i have a servo in esphome which i am using to turn the thermostat for my home heating to adjust the temp during the day (a temporary step before i get smart heating next year).
I have this set up with automations to move the thermostat to set values through out the day to set the house temp automatically which works well.
I would like to be able to have a button on my Overview Dashboard for ‘increase temp’ and ‘decrease temp’. however i am unsure of how to get the current servo position value to increase it by a given amount.
the esphome servo yaml is as follows
substitutions:
name: esphome-web-fad234
friendly_name: Thermostat_control
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
project:
name: esphome.web
version: dev
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
wifi:
ssid: private
password: private
# Set up a wifi access point
ap: {}
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
import_full_config: true
# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
authorizer: none
# To have a "next url" for improv serial
web_server:
port: 80
number:
- platform: template
name: Servo_Control
min_value: -100
initial_value: 0
max_value: 100
step: 1
optimistic: true
set_action:
then:
- servo.write:
id: Hallway_servo
level: !lambda 'return x / 100.0;'
# Example configuration entry
servo:
- id: Hallway_servo
output: pwm_output
# Example output platform
# On ESP32, use ledc output
output:
- platform: ledc
id: pwm_output
pin: GPIO22
frequency: 50 Hz
sensor:
- platform: dht
pin: GPIO23
temperature:
name: "Hallway Temperature"
humidity:
name: "Hallway Humidity"
update_interval: 10s
i have attempted to write a script which i have connected to a button on my dash which has the following
alias: Increase Thermostat Control
sequence:
- data:
entity_id: input_number.Servo_Control
value: "{{ [states('input_number.Servo_Control') | int + 5, 100] | min }}"
action: input_number.set_value
- target:
entity_id: number.Servo_Control
data:
value: "{{ states('input_number.Servo_Control') | int }}"
action: number.set_value
mode: single
unfortunatly i get the following error when i click the button
Failed to perform the action script/increase_thermostat_control. Error rendering data template:
ValueError: Template error: int got invalid input 'unknown' when rendering template '{{
states('input_number.Servo_Control') | int + 5, 100] | min }}' but no default was specified
I’m guessing i am not providing the script with the current value for the servo, but i am unsure how do to that.
If anyone can help point out where i have gone wrong that would be much appreciated.