Input_boolean mqtt switch has stopped working

Has anyone else noticed that their input_boolean mqtt switches have stopped working?

I have two HA controllers. They communicate via MQTT.
Since about a week ago, the mqtt switches set up on the master HA controller have malfunctioned. When I switch one on, it switches off after about 2 seconds. But the other HA controller shows that the slave input_boolean entities have been switched on. And when I switch on the input_boolean on the slave, it does not show up as switched on on the master HA controller.
All the input_select, input_datetime entities that I use are working fine.

All these entities use the same principle of automation subscribing and publishing. Here are examples:

- alias: MQTT publish input_boolean states
  initial_state: 'true'
  trigger:
    platform: state
    entity_id:
      - input_boolean.heater_controlled_by_thermostat
      - input_boolean.pool_temp_calc
      - input_boolean.pool_ice_avoidance
      - input_boolean.pool_summer_timing
      - input_boolean.safety_cut_offs
      - input_boolean.pool_motion_alert
      - input_boolean.no_swimming_today
  action:
    service: mqtt.publish
    data_template:
      topic: "ha2/input_boolean/{{trigger.to_state.object_id}}/state"
      payload: "{{ trigger.to_state.state | lower }}"
      retain: true

- alias: MQTT subscribe input_boolean command
  initial_state: 'true'
  trigger:
    - platform: mqtt
      topic: 'ha2/input_boolean/heater_controlled_by_thermostat/set'
    - platform: mqtt
      topic: 'ha2/input_boolean/pool_temp_calc/set'
    - platform: mqtt
      topic: 'ha2/input_boolean/pool_ice_avoidance/set'
    - platform: mqtt
      topic: 'ha2/input_boolean/pool_summer_timing/set'
    - platform: mqtt
      topic: 'ha2/input_boolean/safety_cut_offs/set'
    - platform: mqtt
      topic: 'ha2/input_boolean/pool_motion_alert/set'
  action:
    service_template: "input_boolean.turn_{{trigger.payload | lower}}"
    data_template:
      entity_id: "input_boolean.{{trigger.topic.split('/')[2]}}"

And here is an example of an MQTT switch:

- platform: mqtt
  name: "Pool pump timer during Summer"
  icon: mdi:pool
  state_topic: "ha2/input_boolean/pool_summer_timing/state"
  command_topic: "ha2/input_boolean/pool_summer_timing/set"
  optimistic: true

I can see using MQTT.fx that the topics are being published correctly in both directions.
I am using Supervisor version 235 on both Raspberry Pi’s. The master is running Raspbian Buster and Docker 19.03.12, and the slave is running HassOS 4.12.
If the other types of entities (input_datetime etc) are working ok might this be a bug, and if so please could anyone advise how I report this?

Thank you for your help.

Further update: I had not saved the optimistic: true additions to the MQTT switches when I wrote the above post.
I have saved this now and the switches on the master HA are now staying on. But I’m away from home so I haven’t yet been able to check if the slave and master HA’s are communicating properly. More later.