-
Notifications
You must be signed in to change notification settings - Fork 58
-
It is more a yaml question than pyscript :-) How would you convert this yaml service call to pyscript?
- service: tesla_custom.api
data:
command: CHARGING_AMPS
parameters:
path_vars:
vehicle_id: '{{ state_attr(''binary_sensor.carname_online_sensor'', ''id'') }}'
charging_amps: '16'
The syntax is: service.call(domain, name, **kwargs)
But I don ́t understand yaml good enough. The domain is, I think, tesla_custom.api, but then I am lost
Beta Was this translation helpful? Give feedback.
All reactions
Answered by
ALERTua
Oct 15, 2023
If I did not mess up the syntax:
carname_online_sensor_value = state.getattr('carname_online_sensor')['id']
service.call('tesla_custom', 'api',
command=CHARGING_AMPS,
parameters=dict(
path_vars=dict(
vehicle_id=carname_online_sensor_value
),
charging_amps='16'
)
)
# or
tesla_custom.api(
command=CHARGING_AMPS,
parameters=dict(
path_vars=dict(
vehicle_id=carname_online_sensor_value
),
charging_amps='16'
)
)
Replies: 1 comment 1 reply
-
If I did not mess up the syntax:
carname_online_sensor_value = state.getattr('carname_online_sensor')['id']
service.call('tesla_custom', 'api',
command=CHARGING_AMPS,
parameters=dict(
path_vars=dict(
vehicle_id=carname_online_sensor_value
),
charging_amps='16'
)
)
# or
tesla_custom.api(
command=CHARGING_AMPS,
parameters=dict(
path_vars=dict(
vehicle_id=carname_online_sensor_value
),
charging_amps='16'
)
)
Beta Was this translation helpful? Give feedback.
All reactions
1 reply
-
Great, thanks.
CHARGING_AMPS needs "", as I got an undefined error. After changing that it works!
This is what I ended up with:
vid = binary_sensor.carname_online.id
tesla_custom.api(
command="CHARGING_AMPS",
parameters=dict(
path_vars=dict(vehicle_id=vid),
charging_amps='16'
)
)
Beta Was this translation helpful? Give feedback.
All reactions
Answer selected by
phsdv
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment