I’m trying to build a series of scripts to automate a laser cat toy that I’ve build, using esp32home.
I’ve exposed the laser and the pan / tilt via esphome and have manual control of it just fine.
Now I want to automate movement and timing using scripts.
I figured I’d start simple and have a script that takes two variables for pan/tilt and set the state.
The code is:
alias: Move Cat Toy
fields:
rotate:
selector:
number:
min: -100
max: 100
step: 1
unit_of_measurement: float
name: Rotate
description: Rotate value for cat toy
default: -69
required: true
tilt:
selector:
number:
min: -100
max: 100
step: 1
unit_of_measurement: float
name: Tilt
description: Tilt value for servo
required: true
default: -33
sequence:
- device_id: b93d5e0023fa0e93fa719916f6da64f3
domain: number
entity_id: b7fbf0ea9ee681f1ce2b38038a5e40fd
type: set_value
value: 0
- device_id: b93d5e0023fa0e93fa719916f6da64f3
domain: number
entity_id: d79cf1e684bae7d9f0ca86b4c9a30899
type: set_value
value: 0
mode: single
icon: mdi:cursor-move
I was expecting that I could just substitute in the fields to the value
section and I’d be good to have it work, but that gives me an error.
...
- device_id: b93d5e0023fa0e93fa719916f6da64f3
domain: number
entity_id: b7fbf0ea9ee681f1ce2b38038a5e40fd
type: set_value
value: "{{ rotate }}"
- device_id: b93d5e0023fa0e93fa719916f6da64f3
domain: number
entity_id: d79cf1e684bae7d9f0ca86b4c9a30899
type: set_value
value: "{{ tilt }}"
...
Error: Message malformed: expected float for dictionary value @ data['value']
How do I coerce what seems to be a type conversion problem?