Template{} Switch as Slider?

Hi ther,

I was able to create multiple switches with the help of the template add-on as discussed here.

Works like a champ so far!

Now I have another sensor which has values from 0-100 (percentage).

Do you guys have an idea how to get the same as above but with a slider?

So an item on the Dashboad which shows the current value but can be set to a different one which will cause a MQTT message to be generated with the desired value?

Thanks for any hints!

/KNEBB

Template number:

Hi,

thanks for your help. Unfortunately I have no clue how to write it with correct syntax in yaml. Where do I put it?

I tried as follows but the syntaax is not correct:

  - platform: number
      lhzr:
        friendly_name: "Luftheizregister"
        state: "{{ sensor.r_lhzr }}"
        set_action: 
            action: mqtt.publish
            data:
              qos: "0"
              retain: false
              topic: hzg/command
              payload: >
                { "name": "hzghaos", "unixtime": {{ as_timestamp(now()) | int(0) }}, "status": {
                "heizung": true, "manuallen": 62,"readcfg":false}, "relais":{"r_lhzr": value } }

Tried with a different header, same result:

  - platform: template
      number:
         lhzr:

Any hint how to configure it?

Thanks!
/KNEBB

Man! this was a tough one. I managed it so far. The following config is now working.

template:
  - number:
    - name: "LHzR Template"
      state: "{{ states('sensor.r_lhzr') }}"
      min: 0
      max: 100
      step: 1
      set_value: 
        action: mqtt.publish
        data:
          qos: "0"
          retain: false
          topic: hzg/command
          payload: >
            { "name": "hzghaos", "unixtime": {{ as_timestamp(now()) | int(0) }}, "status": {
            "heizung": true, "manuallen": 62,"readcfg":false}, "relais":{"r_lhzr": {{ value | int(0) }} } }

Just the link to the doc without further details was a first step but I really had struggled about the syntax. So a short example would have been nice.

Anyways, working now.

Thanks!

/KNEBB

Hi,

justt as a floow-up:

What type of card can I use to intergrate this slider in my dashboard?

Thanks for hints!

/KNEBB

With some luck, I figured it out.

Add this as a card to your dashboard:

type: entities
entities:
  - number.lhzr
title: Luftheizregister
show_header_toggle: true
state_color: true