Radio Buttons for a Central Heating Sytsem

CENTRAL HEATING TIMES SELECTION
(First of all a apology, this is the first time I have posted here, if I have got the formatting wrong then be gentle with me and help me get it right in future. I have inserted 3 ticks ``` around the code but can’t seem to get it acceptable).

I am emulating an old central heating programmer.

I have all the ON/OFF timers working, 3 periods (morning, midday/afternoon and evening/night) and control of the Hot Water and Radiators so that the radiator pump cannot be ON without the boiler being on. It’s all working well so much so that I have turned off the old programmer.

I’m now working on the selection of major times period without having to reprogram the timers every time. This all need a ‘ Dr Zzzs WAF ’ (if you know what I mean).

The issue is I have four buttons as below which I want to use as radio buttons so thy are all mutually exclusive of each other. Not being used to HA and YAML I am pleased with my progress so far but now need some pointers.

Only the [ Programmer ] and [ 24 hours ] buttons act as intended but the others don’t. I also want to make it so there is always one button ON, there must NEVER be all OFF. Help !

LOVELACE PANEL:

LOVELACE CARD

Here’s the image of the four buttons.

Radio_Buttons_001

Nomenclature:

input_boolean.ch_radio_button_xxx

  • ch = Central Heating
  • prg = Programmer
  • day = Day
  • 24h = 24 hours (on continuously)

Shutdown = completely off.

Here’s the YAML, I have removed the STYLE settings for ease of reading.

HELPERS, one for each button (4)

  • input_boolean.ch_radio_button_prg
  • input_boolean.ch_radio_button_24h
  • input_boolean.ch_radio_button_day
  • input_boolean.ch_radio_button_shutdown
type: horizontal-stack
cards:
  - type: button
    tap_action:
      action: toggle
    icon: 'mdi:radiobox-marked'
    name: Programmer (opposite)
    show_state: false
    show_icon: true
    hold_action:
      action: none
    icon_height: 32px
    entity: input_boolean.ch_radio_button_prg
  - type: button
    tap_action:
      action: toggle
    icon: 'mdi:radiobox-marked'
    name: Day (1st ON to last OFF)
    show_state: false
    show_icon: true
    hold_action:
      action: none
    icon_height: 32px
    entity: input_boolean.ch_radio_button_day
  - type: button
    tap_action:
      action: toggle
    icon: 'mdi:radiobox-marked'
    name: 24 Hours (continuous)
    show_state: false
    show_icon: true
    hold_action:
      action: none
    icon_height: 32px
    entity: input_boolean.ch_radio_button_24h
  - type: button
    tap_action:
      action: toggle
    icon: 'mdi:radiobox-marked'
    name: OFF (completely)
    show_state: false
    show_icon: true
    hold_action:
      action: none
    icon_height: 32px
    entity: input_boolean.ch_radio_button_shutdown

SCRIPTS, one for each button (4)

I have executed each script from the /config/script/dashboard and they function as required.

alias: 'CH, Radio Prg Pressed'
sequence:
  - service: input_boolean.turn_on
    data: {}
    entity_id: input_boolean.ch_radio_button_prg
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_day
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_24h
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_shutdown
mode: single

alias: 'CH, Radio Day Pressed'
sequence:
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_prg
  - service: input_boolean.turn_on
    data: {}
    entity_id: input_boolean.ch_radio_button_day
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_24h
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_shutdown
mode: single

alias: 'CH, Radio 24h Pressed'
sequence:
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_prg
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_day
  - service: input_boolean.turn_on
    data: {}
    entity_id: input_boolean.ch_radio_button_24h
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_shutdown
mode: single

alias: 'CH, Radio ShutDown Pressed'
sequence:
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_prg
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_day
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.ch_radio_button_24h
  - service: input_boolean.turn_on
    data: {}
    entity_id: input_boolean.ch_radio_button_shutdown
mode: single

Thanks in anticipation everyone.

(PS — The buttons perform no function at present, I’m waiting to get the sequencing right first. The boiler and pump(s) are actuated by SonOff switches.)

I’ve found my own solution or rather my own error, I was not calling the scripts from the action of the push buttons. I have now corrected this and it all works.

So for anyone else who wants some radio-buttons here’s the amended lovelace YAML. I’ve left the style code in as well.

type: horizontal-stack
cards:
  - type: button
    style: |
      ha-card {
        color: rgb(255,125,125);
        background: rgb(0,0,0);
      }
    tap_action:
      action: call-service
      service: script.ch_radio_prg_pressed
    icon: 'mdi:radiobox-marked'
    name: Programmer (opposite)
    show_state: false
    show_icon: true
    hold_action:
      action: none
    icon_height: 32px
    entity: input_boolean.ch_radio_button_prg
  - type: button
    style: |
      ha-card {
        color: rgb(255,125,125);
        background: rgb(0,0,0);
      }
    tap_action:
      action: call-service
      service: script.ch_radio_button_day_pressed
    icon: 'mdi:radiobox-marked'
    name: Day (1st ON to last OFF)
    show_state: false
    show_icon: true
    hold_action:
      action: none
    icon_height: 32px
    entity: input_boolean.ch_radio_button_day
  - type: button
    style: |
      ha-card {
        color: rgb(255,125,125);
        background: rgb(0,0,0);
      }
    tap_action:
      action: call-service
      service: script.ch_radio_24h_pressed
    icon: 'mdi:radiobox-marked'
    name: 24 Hours (continuous)
    show_state: false
    show_icon: true
    hold_action:
      action: none
    icon_height: 32px
    entity: input_boolean.ch_radio_button_24h
  - type: button
    style: |
      ha-card {
        color: rgb(255,125,125);
        background: rgb(0,0,0);
      }
    tap_action:
      action: call-service
      service: script.ch_radio_off_pressed
    icon: 'mdi:radiobox-marked'
    name: OFF (completely)
    show_state: false
    show_icon: true
    hold_action:
      action: none
    icon_height: 32px
    entity: input_boolean.ch_radio_button_shutdown

I hope this is of some use to someone else. I’m enjoying the challenge of YAML and HA.

1 Like

thanks for coming back to answer. This has helped me

thanks, this helps a lot in maken radio buttons. but I have some questions:
what does this code do? I removed it on all places and it seems that nothing changes. And I see no items with this rgb foreground colors. I removed it because the style function gave warning (not supported) in the visual editor.

    style: |
      ha-card {
        color: rgb(255,125,125);
        background: rgb(0,0,0);
      }

Mybe I don’t have something like a ha-card

I see the radio buttons change color from black to yellow. where and how do you do that or is that a HA intrinsic function?

isn’t it possible to not only change the color but also the icon from a radiobox-clear to a radiobox-marked when you chage from inactive to active (and back of course)