Create custom switch using rfxtrx.send

Hey !

I’m fairly new to home assistant and I don’t know a single thing about coding. I’m still a bit lost with the entity system.

I have an unsupported pellet stove I’d like to turn on and off and using a generic thermostat and rfxtrx to send the command. I managed to create a simple switch to turn it on and off manually, but I’d like to be able to automate it a bit.

The RFXTRX add-on doesn’t recognize the command when I try to add entities from their panels, but the commands I got from rfxmngr work fine when I use the send command manually.

My idea is to create an entity that would be recognized by the generic thermostat add-on as a heating device, which sends a command to turn it on via rfxtrx.send, and a different one to turn it off. There’s no state feedback possible (the stove just receives commands).

Does any of you know how I could do that please?

The Generic Thermostat integration creates a climate entity… to do that, it requires a switch/toggle entity and a thermometer.

If the RFXTRX integration isn’t able to create a switch entity for you, another option would be to use a Template Switch. You will need to set it to act optimistically since you have no actual feedback.

1 Like

Thank you for your answer. I tried coming up with something based on the wiki in the template menu, it looks like this :

template:
  - switch:
      - name: "Poêle à granulés"
        turn_on:
          action: rfxtrx.send
          data:
            event: 0C430111000002010111020200
          target:
            entity_id: switch.poele
        turn_off:
          action: rfxtrx.send
          data:
            event: 0C430113000002010111020000
          target:
            entity_id: switch.poele

But I have no idea if it would work, or how to use this outside the template menu… Do I add it to the configuration.yaml file?

That looks okay. I’m not sure if it’s required since you didn’t define a state template, but it wouldn’t hurt to add optimistic: true… just in case.

Since you aren’t using any of the advanced configuration options you can set it up either in your configuration.yaml file or you can do it through the Helpers tab. Whichever you prefer.

1 Like

The first solution didn’t work, it did create the switch with the entities but it didn’t work

I tried this version too with no success :

template:
  - switch:
      - name: Poele
        state: "{{ is_state('sensor.poele.state', 'off') }}"
        optimistic: true
        turn_on:
          action: rfxtrx.send
          data:
            event: 0C430111000002010111020200
          target:
            entity_id: switch.poele
        turn_off:
          action: rfxtrx.send
          data:
            event: 0C430113000002010111020000
          target:
            entity_id: switch.poele

In both case I have the following error : extra keys not allowed @ data[‘entity_id’]

Based on the error and the docs, the rfxtrx.send doesn’t use a target.

image

template:
  - switch:
      - name: Poele
        optimistic: true
        turn_on:
          - action: rfxtrx.send
            data:
              event: 0C430111000002010111020200
        turn_off:
          - action: rfxtrx.send
            data:
              event: 0C430113000002010111020000
1 Like

Oh my god, I’m an idiot haha, you’re right, it works that way !

Thank you so much for your help !