KlikAanKlikuit switch style

Hi There,

As a starter with HA i’m running into some strange behavior - which is hopefully explainable… I have setup my RFXCOM device on HA and it is auto-adding the devices received from the KAKU remote.

But the devices are added with an on/off switch of two flashes, where my MQTT switches have a nice looking on/off toggle. I cannot find any way to change the (actual)switch icon. The device icon is easy to setup :slight_smile:

See:
image

Hopefully someone would be able to get me in the right direction!? Thanks!

Roel.

The easiest is to change the switch.xyz_very_long_code to light.xyz_very_long_code. Just copy the same numbers and letters behind switch. to light. and it will act as a light.

Hi @Ernst

Thanks for the quick reply! However changing switch. to light. remains with the same graphical “error”.
I followed this guide for the install:

Currently this is my switches / light configuration.yaml:

switch:
  - platform: mqtt
    name: ho_links
    icon: mdi:lamp
    state_topic: "stat/ho_links/POWER"
    command_topic: "cmnd/ho_links/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
  - platform: mqtt
    name: ho_rechts
    icon: mdi:desk-lamp
    state_topic: "stat/ho_rechts/POWER"
    command_topic: "cmnd/ho_rechts/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
  - platform: mqtt
    name: wk_hoeklamp
    icon: mdi:floor-lamp
    state_topic: "stat/wk_hoeklamp/POWER"
    command_topic: "cmnd/wk_hoeklamp/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"

light:
  - platform: rfxtrx
    automatic_add: true
    devices:
      0b110000007b452201010f70:
        name: ho_hoeklamp

When i change the ligth to something like, home assistant won’t restart.

light:
  - platform: rfxtrx
    name: 0b110000007b452201010f70

Thanks

Ah, sorry, you’re right. I changed my switches to lights to all have the flash icons. But you want the switch button, so the other way around.

In my case, I changed my switch to a light by this code:

light:
  - platform: switch
    name: Staanlamp woonkamer
    entity_id: switch.staanlamp_woonkamer

Did you try it the other way around, making a switch from a light?

switch:
  - platform: light>
    name: ho_hoeklamp
    entity_id: light.ho_hoeklamp

Not sure whether this is possible, but give it a try.

Edit: Nevermind, this doesn’t seems to be valid code. Not sure how to help. Maybe a template switch can help you?

Hello,

I had the exact same problem and managed to resolve it by setting the assumed_state parameter to false in the customize.yaml file for every problematic device.

This is due to the fact that RFXTRX platform does not allow state reporting of a device. The workaround on HA side was to assume that the state of the device changed after an order. But in case the device state did not changed, you can still click on the correct button in the frontend.

Hi @Frixx

Thanks for your reply! I thinkg your solution is just to assume that the device is off - due the lack of reporting on the RFXTRX. Just setting the state is not what i’m looking for.

I would like to have the same switch as the other switches (ho_links, ho_right) as shown in the image in my original post. Basically purely cosmetic. Another thing is to add some MQTT bit and pieces and have the RXTX trigger some automation.

Thanks

Just an update from my end. I found myself a solution :slight_smile: Here is my solution for the next one who runs into this issue.
image

I have replaced the rfxtrx button for an MQTT button. I basically publish in a command topic, an automation publishes to the state topic and calls the light.turn_on service. Pieces of my config:

# configuration.yaml

switch:
  - platform: mqtt
    name: ho_hoeklamp
    icon: mdi:floor-lamp
    state_topic: "stat/ho_hoeklamp/POWER"
    command_topic: "cmnd/ho_hoeklamp/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
# configuration.yaml

light:
  - platform: rfxtrx
    automatic_add: false
    devices:
      0b110000007b452201010f70:
        name: 433_ho_hoeklamp
# automations.yaml

- id: '1563438758056'
  alias: ho_hoeklamp on
  trigger:
  - payload: 'ON'
    platform: mqtt
    topic: cmnd/ho_hoeklamp/POWER
  condition: []
  action:
  - data:
      payload: 'ON'
      topic: stat/ho_hoeklamp/POWER
    service: mqtt.publish
  - data:
      entity_id: light.433_ho_hoeklamp
    service: light.turn_on
- id: '1563438758060'
  alias: ho_hoeklamp off
  trigger:
  - payload: 'OFF'
    platform: mqtt
    topic: cmnd/ho_hoeklamp/POWER
  condition: []
  action:
  - data:
      payload: 'OFF'
      topic: stat/ho_hoeklamp/POWER
    service: mqtt.publish
  - data:
      entity_id: light.433_ho_hoeklamp
    service: light.turn_off

I have setup my automation via configuration -> automations.

Edit: Got the assumed_state working aswell. However the MQTT option gave me more flexibility.

I would suggest you to try custom:button-card, this avoids you to do “hacky” stuff like you did here and those buttons are really flexible in every way.

Your solution would work perfectly fine though. But this button will make your setup a whole lot better. Here is an example of one of those buttons:

Do you mind sharing a piece of your actual config?

You can find it here:

I warn you though, it is probably a bit daunting for beginners. Though, I am always willing to help out (via discord and/or remote desktop) if you so desire. I see you are Dutch and if you live reasonably close to Eindhoven I could even come to help out.

For an easier solution you could check my older repos on github (they are a bit easier to understand). I hope this helps you out.