Remote_transmitter switch trigger automation

I’ve successfully created a IR transmitter with a ESP8266. I also integrated it with hass but when I try to create a automation that triggers when I use one of the remote switches(so that I can assume a state of another entity: So when I click on the turn on switch I set a input boolean to on and when I use the turn off switch I set the input boolean to off)
I have a very simple automation but it simply wont trigger:

automation:
  - id: "turn_on_receiver_input_boolean"
    alias: Turn on receiver input boolean
    initial_state: true
    trigger:
      - platform: state
        entity_id: switch.receiver_on
    action:
      - service: input_boolean.turn_on
        entity_id: input_boolean.receiver_on

And if I look in the history of the switch it’s never toggled.
The switch entity is created by the esphome integration.
Anyone have a solution for this?

The automation looks ok to me. So if it’s not working then that means the switch.receiver_on state is not changing. Things you can do.

  1. Use the DeveloperTools/States to display the switch state. Activate the switch. You should see the state change.
  2. Turn on logging for automations by modifying your configuration.yaml with the following and then monitor the logs at Developer Tools/Logs.
  3. You could also add a test input_boolean to your setup and trigger your automation with it to see if the automation executes.
logger:
  default: warning
  logs:
    homeassistant.components.automation: debug

In the developer tools it doesn’t switch state and also in the history it’s always off so I know it doesn’t switch state. The question is can I make it switch state or let a automation trigger on something else then state.
The switch works so when I ‘turn on’ the switch I see that the ir command is fired.

Are you saying the switch.receiver_on doesn’t change state or the input_boolean.receiver_on doesn’t change state?

The switch doesn’t change state even when you ‘turn it on’

There isn’t really anything else to trigger off of other than the state. Ls the switch implemented in the 8266? If that is the case, then there is something wrong with either the esp implementation or how you linked it to HA. Since it shows in HA then I guess one would have to assume have to assume the implementation or state publishing is faulty. What does your esp code look like for the switch?

The switch is a remote transmitter in esp home(ir led to send it codes) so it isn’t an on off switch but rather a push button. I thinks that’s also the reason why it doesn’t really change state because Hass doesn’t know push buttons

Sorry, perhaps a picture? Is the 8266 a transmitter of ir or a receiver?
My guess is you have created an ir receiver out of 8266 with esphome. When it receives an ir signal it momentarily turns on. Since you implemented it as a pushbutton it then turns off. You’ve also connected this pushbutton to HA and it’s named switch.receiver_on.
HA’s smallest time increment is a second. So yes if the pushbutton duration is shorter than a second you will have problems. If you pushed it enough times you might catch an edge on occasion but the results would probably be sporadic at best. Since you also talked about an off signal why not implement a latched signal in the 8266 that turns on with the on signal and then turns off with the off signal. That won’t be a problem in your HA automation as it will only trigger with a state change and you could create an automation that handles both on and off states as opposed to just one. Just a thought.

Hi, thanks for helping me!
It’s a transmitter. only in hass these commands show up as swtiches(which is logical because how else would you fire a command) here’s my code for esphome:

esphome:
  name: receiver
  platform: ESP8266
  board: d1_mini_pro

wifi:
  ssid: "*****"
  password: "****"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Receiver Fallback Hotspot"
    password: "*****"

captive_portal:

# Enable logging
logger:


# Enable Home Assistant API
api:
  password: "******"

ota:
  password: "*****"
remote_transmitter:
  pin: D2
  # Infrared remotes use a 50% carrier signal
  carrier_duty_percent: 50%
  
switch:
  - platform: template
    name: sony power
    turn_on_action:
      - remote_transmitter.transmit_sony:
          data: '0x00000A90'
          nbits: 12
          repeat:
            times: 3
  - platform: template
    name: Receiver on
    turn_on_action:
      - remote_transmitter.transmit_lg:
          data: '0x616E02FD'
          nbits: 32
      - remote_transmitter.transmit_nec:
          address: '0x616E'
          command: '0x02FD'
      - remote_transmitter.transmit_raw:
          code: [9026, -2184, 645]
      - remote_transmitter.transmit_raw:
          code: [9001, -2209, 649]
      - remote_transmitter.transmit_jvc:
          data: '0x010E'
      - remote_transmitter.transmit_lg:
          data: '0x010E6A95'
          nbits: 32
      - remote_transmitter.transmit_nec:
          address: '0x010E'
          command: '0x6A95'
      - remote_transmitter.transmit_raw:
          code: [9000, -2209, 648]
      - remote_transmitter.transmit_raw:
          code: [9000, -2209, 649]
  - platform: template
    name: Receiver off
    turn_on_action:
      - remote_transmitter.transmit_jvc:
          data: '0x616E'
      - remote_transmitter.transmit_lg:
          data: '0x616E827D'
          nbits: '32'
      - remote_transmitter.transmit_nec:
          address: '0x616E'
          command: '0x827D'
      - remote_transmitter.transmit_raw:
          code: [9059, -2150, 649]
      - remote_transmitter.transmit_raw:
          code: [9000, -2209, 648]
      - remote_transmitter.transmit_jvc:
          data: '0x010E'
  - platform: template
    name: Volume down
    turn_on_action:
      - remote_transmitter.transmit_jvc:
          data: '0x616E'
      - remote_transmitter.transmit_lg:
          data: '0x616E2AD5'
          nbits: '32'
      - remote_transmitter.transmit_nec:
          address: '0x616E'
          command: '0x2AD5'
      - remote_transmitter.transmit_raw:
          code: [8980, -2234, 561]
  - platform: template
    name: Volume up
    turn_on_action:
      - remote_transmitter.transmit_jvc:
          data: '0x616E'
      - remote_transmitter.transmit_lg:
          data: '0x616E2AD5'
          nbits: '32'
      - remote_transmitter.transmit_nec:
          address: '0x616E'
          command: '0xCA35'
      - remote_transmitter.transmit_raw:
          code: [8966, -2238, 561]
  - platform: template
    name: Speakers 1
    turn_on_action:
      - remote_transmitter.transmit_jvc:
          data: '0x616E'
      - remote_transmitter.transmit_lg:
          data: '0x616E42BD'
          nbits: '32'
  - platform: template
    name: Speakers 2
    turn_on_action:
      - remote_transmitter.transmit_jvc:
          data: '0x616E'
      - remote_transmitter.transmit_lg:
          data: '0x616EC23D'
          nbits: '32'

As you can see it’s a transmitter. And if you look at the docs https://esphome.io/components/remote_transmitter.html they are configured as switches.(again looks logic to me) only thing I’m trying to find a way to trigger an automation when one of these switches is ‘turned on’ (fired) but I think I’m out of luck.

okey searched a bit and found out I can add:
optimistic: True
assumed_state: True
Now it triggers the automation only the the switch keeps on. Maybe I fix that with an automation

1 Like

I’m not sure what you’re trying to accomplish, but have you considered using a script?

I’ve made a esp8266 with an IR transmitter. This works perfectly.
Now I’m trying to make a media_player out if it. I’ve created a custom_component(https://github.com/Sennevds/media_player.template) where you can define services for each action.

This all works the only problem is that I don’t know if the receiver is on or off(in time I want to maybe use a non-invasive power meter) but at this moment I just thought if the switch.receiver_on state changed I set a input_boolean to on.

With the two arguments I’ve added it works now I’ve only changed my esp code and added turn_off_action for each switch to send the same code as the turn_on_action.

Now evertyhing works. Thanks for your help!

Is there no output on the back you can use to know the state?
HDMI ports have a 5 volt pin, SCART have a 12 volt pin, most have a USB port.
I know for sure you can’t power a 8266 from the HDMI, not sure about the SCART though (mind there is a large voltage peak also), but you can definitely use both to see if it’s on or off.
Same with the USB.

No it’s an older Harman Kardon hk 3390 (I only used as stereo receiver I have a seperate AVR).
At this moment I send my “IR” signal through the remote in port which is nice because then I don’t need IR transmitter in front of the device. Maybe I could check if the video output has a voltage when it’s turned on but I’ve never attached the receiver to my tv.

Most likely it does.
What kind of connection is it?

Component I’m trying to connect it to my tv but no video output. Going to check the manual.
Edit: found the following in the manual

No video signal will be available with an audio-only source, such as CD or Tape.

So I think I’m out of luck for that

In that case photoresistor on internal or external LED is the only option apart from your idea

1 Like

Going to check if I have a photoresistor lying somewhere

Thanks for that. I had the same issue as you.