Quantcast
Channel: ESPHome - Home Assistant Community
Viewing all articles
Browse latest Browse all 1486

How to read a variable from a custom_component (wiegand)

$
0
0

@Stepan wrote:

Hi all!
I got stucked with my first custom integration.
I want to integrate a rfid reader.

I have use the code from gdoerr
The code has been successfully read with my rfid reader and printed in the ESPhome logger

Now I have two choices.
1. I can publish the code to my “controlAccess” topic which has a script to check the access permission of the code. But my problem is I need 3 variables to complete the logic proccess:
payload= {
‘id’: ‘door’,
‘code’: wiegand_code,
‘timeStamp’: now()
}
and I dont know if would be possible to build in my esphome.yalm this structure and publish the json directly from the device in to the topic.

2. I could call a script which process the code and build the complete payload.
My problem is that the the script is not tiggered with this config and I dont know why.
My ESPhome yaml is:

custom_component:
  - lambda: |-
       auto wiegand = new WiegandReader(21, 23, "python_scripts.door_mqtt_publish.py");
       return {wiegand};

in config/python_scripts/door_publish_mqtt.py I have a simple code just to test it

logger.info("PYTHON SCRIPT CALLED")
name = data.get('code')
logger.info("HELLOOOOOOOOO %s", name)
hass.bus.fire(name, {"test": "from a Python script!"}
)

and I think that services is not mandatory, anaway:
config/python_scripts/services.yaml

door_mqtt_publish:
  description: publish a rfid code
  field:
    code:
      description: code format
      example: 9451293

In the ESP home logger I can see that the code is read perfectly but I can not trigger the python script to send the payload with the code on it. After read a code nothing appears in the HA logger.

HA logger:

2020-02-03 12:25:05 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2020-02-03 12:25:05 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for customizer which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2020-02-03 12:25:36 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1908784496] Error handling message: Unauthorized

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 1486

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>