Forward states directly from mysensors to dmx device

Hey,

I receive messages from mysensors mqtt gateway to home assistant. There are many messages (led brightness adjustment) in short period of time. I want HA immediately forward values received from mysensors gateway to light entity defined in HA.

For now I achieve it somehow, but it is not efficient. I created automation that on mqtt message forwards value to the light device but there are so many messages that when automation is triggered it doesn’t forward the newest value.

- alias: "Forward do art-net dmx"
  trigger:
    platform: mqtt
    topic: mygateway1-out/42/2/1/0/3
  action:
    service: light.turn_on
    data_template:
      entity_id: light.house_lights
      brightness: "{{ state_attr('light.Test_42_2', 'V_PERCENTAGE') }}"

Is there a way that two device entities are linked together so values are synchronized directly without complexity overhead? How to solve it in a better way?

Best regards,
Mariusz

Have you tried using the Template Light?

Sorry for the late response, today I had the time to play with it.

Unfortunately, my template I prepared doesn’t work (value 12 nor 17 are not passed to the house_lights entity). Even there is no print in home assistant logs saying template was matched (not sure whether it should print anything?).

light:
  - platform: template
    lights:
      dmx_light:
        friendly_name: "Forward dmx(new)"
        value_template: "{{ states.light.Test_42_2.attributes.V_PERCENTAGE|int }}"
        level_template: "{{ states.light.Test_42_2.attributes.V_PERCENTAGE|int }}"
        set_level:
          service: light.turn_on
          data_template:
            entity_id: light.house_lights
            brightness: "23"
        turn_on:
          service: light.turn_on
          data_template:
            entity_id: light.house_lights
            brightness: "17"

I checked pattern set in value_template on template debugger and it retrieves the value correctly.

Do you have an idea what I did wrong or how I can debug it?

Best regards,
Mariusz

Hey again,

I solved it by changing the way how I send info about dimmable values.
I changed approach to send only ‘start’ event and ‘end’ event of dimming and make a step of brightness in AppDaemon. See adamja solution: App that cycles a lights brightness between max and min while a button/switch is held down

Best regards,
Mariusz