Automation of gpio Led when known device home

Hi to all,
i want to switch a led on when a known device is in “home” state.

i tried like this in automation.yaml:

# led automation when home
- alias: 'Home Signal'
  trigger:
    platform: state
    entity_id: known_devices.m_honor_90
    state: home
  action:
    - service: switch.turn_on
      data:
        entity_id: switch.Led_Red
```

Change “state: home” to “to: home”. Also you need to track a device_tracker entity_id. So verify that you have one defined for your mobile device. The code should then look like this:

i tried changing that, but i´m only getting this error in protocol:
Logger: homeassistant.components.automation
Source: components/automation/config.py:242
Integration: Automatisierung (documentation, issues)
First occurred: 18:44:25 (1 occurrences)
Last logged: 18:44:25

Automation with ID ‘Led anzeige’ could not be validated and has been disabled: required key not provided @ data[‘action’]. Got None required key not provided @ data[‘trigger’]. Got None

this is the switch in configuration.yaml:

##GPIO
# led Gpio switch
switch:
  - platform: rpi_gpio
    ports:
      18: led_red

by clicking on the switch itself it works but not with the automation

Please post your automation yaml. Is device_tracker.m_honor_90 defined?

thanks for your help i found the error:

  alias: 'Home Signal'
  description: ''
  trigger:
  - platform: state
    entity_id:
    - device_tracker.m_honor90lite
    from: not_home
    to: home
  condition: []
  action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.led_red
  mode: single