I have an mqtt sensor that holds a numeric value that is a percentage of progress.
mqtt:
sensor:
- name: "Elegoo N4plus Print Progress"
unique_id: "sensor.elegoo_n4plus_print_progress"
unit_of_measurement: '%'
icon: mdi:printer-3d-nozzle
state_topic: "neptune4p/printprogress"
qos: 0
As an example the state of the above entity is currently set to 65
I wanted to use this sensor value in a mushroom number card to show progress of a 3d print, but the mushroom card expects only a number or input_number.
I’m trying to use a template to populate a number with the value from the sensor; but I can’t seem to get the syntax right. Anyone have an example of something similar or see where I might be off-track?
template:
- number:
- name: 3d_print_progress
unique_id: 3d_print_progress
state: "{{ states('sensor.elegoo_n4plus_print_progress') }}"
step: "1"
set_value:
action: number.set_value
target: number.3d_print_progress
data: "{{ value }}"
I’ve also tried (without success)
data: "{{ states('sensor.elegoo_n4plus_print_progress') }}"
I’m seeing this in the logs after I re-load the template entities using developer tools
Invalid config for 'template' at configuration.yaml, line 1223: expected dictionary 'number->0->set_value->0', got 'n'
Invalid config for 'template' at configuration.yaml, line 1219: invalid template (TemplateSyntaxError: Encountered unknown tag 'states'.) for dictionary value 'number->0->state', got '{% states(sensor.sensor.elegoo_n4plus_print_progress) %}' Invalid config for 'template' at configuration.yaml, line 1223: expected dictionary 'number->0->set_value->0', got 'n'
Invalid config for 'template' at configuration.yaml, line 1219: expected dictionary 'number->0->set_value->0', got '{'
Invalid config for 'template' at configuration.yaml, line 1220: expected dictionary 'number->0->set_value->0', got '{'
Invalid config for 'template' at configuration.yaml, line 1221: expected a dictionary for dictionary value 'number->0->set_value->0->target', got None
Thanks!
Joe