Automation - Actions over MQTT

On the page https://www.home-assistant.io/docs/automation/action/ there are no example on publish state over MQTT broker .

I would like to set up an automation that ower MQTT turn on a lamp at time 21:15:00

The code bellow works fine when troggel the light from the dashboard.

light:
  - platform: mqtt
    name: "Light"
    command_topic: "inLight"
    state_topic: "inLight"
    payload_on: "0"
    payload_off: "1"
    retain: true

my code on controler

if (client.connect("Light"))

    {

        Serial.println("Light - MQTT - OK");

        client.subscribe("inLight");

    }

in /config/automations.yaml i have this code, that i think has to be modified , So do anyone has a sugestion ?

- id: 'xxxxxxxxx'
  alias: mqtt turn on light
  description: ''
  trigger:
  - platform: time
    at: '21:15:00'
  condition: []
  action:
  - service: mqtt.publish
    data:
      light.turn_on: true
  mode: restart

The action is light.turn_on, home assistant communicates to the MQTT broker when it turns the light on.

Thank you for your comment.
I have edit my post and added the code in /config/automations.yaml. This code dos not work for me.

light.turn_on is a service. It should be:

  action:
  - service: light.turn_on
    data:
      entity_id light.whatever

Hi i got this error code:
“Message malformed: extra keys not allowed @ data[‘action’][0][‘action’]”

 action:
  - service: light.turn_on
    data:
      entity_id light.inLight

Hi. I found the correct syntax.
Thank you for your support, have a nice day / Tomas

service: light.turn_off
data: {}
entity_id: light.light

Sorry about that, looks like you figured it though :slight_smile: