#3d print On/Off event to rest_command

1 messages · Page 1 of 1 (latest)

uncut iron
#

How do I insert the either on or off part of the event into the rest_command ? I currently have two commands but I want to insert the on/off even so I only need one command. Here are my two commands : ```
rest_command:
office_tronbyt_octoprint_app_disable:
url: "http://192.168.1.10:8000/v0/devices/9abe2858/installations/649"
method: put
content_type: "application/json"
payload: "{"set_enabled":false}"
headers:
Authorization: CHANGEME
officce_tronbyt_octoprint_app_enable:
url: "http://192.168.1.10:8000/v0/devices/9abe2858/installations/649"
method: put
content_type: "application/json"
payload: "{"set_enabled":true}"
headers:
Authorization: CHANGEME

glacial tide
#

you can pass in a variable defined as true or false, and then presumably use it in the rest_command definition in the payload

uncut iron
#

the docs don't explain how to pass in the on/off into the command though. How do I know what the on/off variable from the 3d printer turning on or off is called ? Entity value or solmething.

glacial tide
#

they do

#

what part is confusing?

#

the show how to pass a variable in, and give an example of how it's used in the command

uncut iron
#

How do I find out the name of the either on or off state of the 3d printer to use in the command ?

#

This is the info screen for the plug controlling the 3d printer

glacial tide
#

the examples are the actual YAML you would use

#

it's possible that you can't provide data to the rest_command via the UI

uncut iron
#

so in this example how would I pass the "enter" into the res_command ? ```automation:

  • alias: "Arrive at Work"
    triggers:
    • trigger: zone
      entity_id: device_tracker.my_device
      zone: zone.work
      event: enter
      actions:
    • action: rest_command.my_request
      data:
      status: "At Work"
      emoji: ":calendar:"```
glacial tide
#

I didn't even know you could do it until I looked at the docs

uncut iron
#

because it's possible that all the trigger info is getting passed in I just don't what it's called.

#

here is the yaml in the gui editor platform: device type: changed_states device_id: bda466a1df09d3448485e212f1b6a790 entity_id: 72e182da2563def2a27e1f8a9615b5e1 domain: switch

#

the state changes but to what ? and is that passed to the rest_command ?

#

I guess I can try to explicity call it via the states. thingy rest_command: post_meterstanden: method: POST url: 'https://www.mindergas.nl/api/gas_meter_readings' headers: content-type: application/json AUTH-TOKEN: !secret: token payload: '{"date" : "{{states.sensor.yesterday.state}}","reading" : {{ states.sensor.gas_consumption.state }}}'

#

so maybe use this, but then how do I use true for on and false for off ?

#

oh, the traces windo is helping alot.

#

is this proper syntax ?

glacial tide
#

not quite

#

But if the state you want is already in an entity, then you don't need to pass it as a parameter at all. But you do need to change it from a string to a boolean

#

note that the example above refers to the state of an entity directly

uncut iron
#

this works.

#

then rest_command: garage_tronbyt_octoprint_app_control: url: "http://192.168.1.10:8000/v0/devices/e32753c8/installations/548" method: put content_type: "application/json" payload: "{\"set_enabled\": {{ set_enabled }}}"

glacial tide
#

you can just put that directly in the rest_command rather than making a variable with it and passing it in