Is there a fast way for sending mqtt payload?

Hi!

I am sending payload (ir codes) to my self made ir blaster (eps8266 device) that then blasts the code to my devices. My VSX-S300 AV-Receiver want’s to get the power on signal for at least 3 times in a fast sequence to power on at all. At the moment I try it with this:

script:

  vsx_poweron:
    alias: "VSX S300 Power On Script"
    sequence:
      - service: homeassistant.turn_on
        data:
         entity_id: switch.vsx_poweron
      - service: homeassistant.turn_on
        data:
         entity_id: switch.vsx_poweron
      - service: homeassistant.turn_on
        data:
         entity_id: switch.vsx_poweron
      - service: homeassistant.turn_on
        data:
         entity_id: switch.vsx_poweron

switch:

 - platform: mqtt
   name: "vsx_poweron"
   state_topic: "home/living/u-ir-remote-1/state"
   command_topic: "home/living/u-ir-remote-1"
   qos: 1
   payload_on: "sendgc:38000,1,1,360,180,22,67,22,22,22,67,22,22,22,22,22,67,22,22,22,67,22,22,22,67,22,22,22,67,22,67,22,22,22,67,22,22,22,22,22,67,22,22,22,67,22,67,22,22,22,22,22,22,22,67,22,22,22,67,22,22,22,22,22,67,22,67,22,67,22,989,360,180,22,67,22,22,22,67,22,22,22,22,22,67,22,22,22,67,22,22,22,67,22,22,22,67,22,67,22,22,22,67,22,22,22,22,22,67,22,22,22,67,22,67,22,22,22,22,22,22,22,67,22,22,22,67,22,22,22,22,22,67,22,67,22,67,22,989"

A script with mqtt.publish etc won’t work either…

If I send the payload with the built in mqtt.publish tool in HASS and I press the button fast for three times, it works like a charm. so there is no problem with my ir blaster device. It works fast enough. Problem seems to be the execution time of the script.

Is there a faster way of sending mqtt messages to my device? Say 3 times a second?

Solution is here: Solution in #4

You can use the MQTT Publish service directly, rather than going through a switch, although I don’t know if this will be quicker.

From a system design, it would be more reliable getting your blaster to do this low level kind of interface.

Thanks for your input. I used mqtt.publish service within a script. It’s not fast enough.

My IR blaster does the low level stuff. It takes the payload and sends it. it’s fast enough for any task and reacts at least 5 or 6 times a second. The blaster even works by pushing the mqtt switch 4 times a second by mouse click.

As my blaster is installed in the ceiling and the OTA does not work at the moment I try to not go the way of programming a repeat function or something. I want to keep it simpel. HASS for the logic and scripting and so on and my blaster for the physical stuff / communication stuff.

Perhaps some python script could be a solution. But then again it’s a layer more of complexity…

I found the solution. Use a delay with milliseconds defined… As simple as this:

vsx_poweron:
alias: “VSX S300 Power On Script”
sequence:
- service: homeassistant.turn_on
data:
entity_id: switch.vsx_poweron
- delay:
milliseconds: 200
- service: homeassistant.turn_on
data:
entity_id: switch.vsx_poweron
- delay:
milliseconds: 200
- service: homeassistant.turn_on
data:
entity_id: switch.vsx_poweron
- delay:
milliseconds: 200
- service: homeassistant.turn_on
data:
entity_id: switch.vsx_poweron

Some additional links about this topic:

1 Like

I have two suggestions. First, you could change the logic in the program you have running on the ESP8266 to transmit the turn on sequence three times. You send the command once with MQTT and let the ESP8266 handle the details. Secondly, you could switch from using MQTT to using a RESTful command. In some circumstances, Rest is much faster that using MQTT. I’m using an ESP8266 to control my garage door. I originally set it up using MQTT and it took several seconds for my door to react after selecting open door from the HASS frontend. After I switched to REST, the door reacts immediately.