I am using following service call in the dev-tools to test a python script service “set_state”:
service: python_script.set_state
data:
entity_id: input_number.huis_gasverbruik_het_laatste_hele_uur
state: "{{states('sensor.huis_gasverbruik')}}"
allow_create: true
This one works and does what is expected.
Then I created the following services.yaml in the /python_scripts folder, for better documenting. as pointed out in: “Phyton Scripts”:
set_state:
name: Zet gasverbruik
description: Detecteer een spike d.m.v. trigger en maak deze geldig voor het hele uur
fields:
entity_id:
description: The input-identity to get a new state
example: input_number.huis_gasverbruik_het_laatste_hele_uur
default: input_number.huis_gasverbruik_het_laatste_hele_uur
state:
description: The state you want to take over
example: "{{states('sensor.huis_gasverbruik')}}"
default: "{{states('sensor.huis_gasverbruik')}}"
allow_create:
description: Recreates the input-identity (when <true>), when needed.
example: true
default: true
When I put the last part in place and reload, I’m getting indeed a nice template and when I press the “Fill examples” button everything is nicely filled, but for the line with “state” I’m getting a strange result:
service: python_script.set_state
data:
entity_id: input_number.huis_gasverbruik_het_laatste_hele_uur
state:
"[object Object]": null
allow_create: true
I’m new to HA (not to home automation and programming), can somebody point me in the right direction to get this working? I did already try variants with single quotes less accolades etc. but no joy.