Please help, I am getting nuts. I fail to take the first step as a newbe.
My goal and first step is to use Python in HA. For that I created a Button in the main panel. I found its script editor and made my button to work.
type: button
entity: input_button.trigger_python_script
tap_action:
action: toggle
The button keeps pressed and I guess that is what is expected. Then I added the sample script from AlexxIT in the same yaml:
script:
test_source:
sequence:
- service: python_script.exec
data:
title: Python inline test
source: |
import requests
r = requests.get('https://api.ipify.org?format=json')
resp = r.json()
logger.warning(resp)
hass.services.call('persistent_notification', 'create', {
'title': data['title'],
'message': f"My IP: { resp['ip'] }"
})
Question: How do I change my button so that it calls the embedded script correctly and how can I check its workings. Note that the log entry is of the level warning so I expect it to show in my log