pmazz / ps_hassio_entities

Python script to handle state and attributes of existing sensors and entities
MIT License
58 stars 10 forks source link

Can you please share one example to using the script in an automation or script [QUESTION] #1

Closed tomerbs closed 4 years ago

tomerbs commented 4 years ago

What is your question Can you please share one example of using the script in an automation or script.

YAML configuration


# paste your configuration here
`'1596141541557':
  alias: '###New Script Off'
  sequence:
  - data:
      action: set_state_attributes
      entity_id: binary_sensor.neo_coolcam_door_sensor
      state: 'off'
    service: python_script.hass_entities``

**Screenshots**
If applicable, add your screenshots here.

**Version**
What is the version of the script?
I'm using version 1.1.0

**Additional information**
I was able to get it to work from lovelace but from an automation and script It's not working for meץ
pmazz commented 4 years ago

Your code is missing the attributes: array. Invoking the set_state_attributes action requires to provide both state and attributes.

So your code should be:

'1596141541557':
  alias: '###New Script Off'
  sequence:
  - data:
      action: set_state_attributes
      entity_id: binary_sensor.neo_coolcam_door_sensor
      state: 'off'
      attributes:
        - attribute1: 'attribute value'
        - attribute2: 'attribute value'
    service: python_script.hass_entities

Check here for details: https://github.com/pmazz/ps_hassio_entities#set-both-state-and-attributes

Or, in case you need to set the state only, your should use action: set_state. Then your code should be:

'1596141541557':
  alias: '###New Script Off'
  sequence:
  - data:
      action: set_state
      entity_id: binary_sensor.neo_coolcam_door_sensor
      state: 'off'
    service: python_script.hass_entities

Check here for this case: https://github.com/pmazz/ps_hassio_entities#set-state-only

Let me know if that helps.

tomerbs commented 4 years ago

Thanks a lot, it's working now.😉

בתאריך יום ו׳, 31 ביולי 2020, 01:23, מאת Paolo Mazzini ‏< notifications@github.com>:

Your code is missing the attributes: array. Invoking the set_state_attributes action requires to provide both state and attributes.

So your code should be:

'1596141541557': alias: '###New Script Off' sequence:

  • data: action: set_state_attributes entity_id: binary_sensor.neo_coolcam_door_sensor state: 'off' attributes:
    • attribute1: 'attribute value'
    • attribute2: 'attribute value' service: python_script.hass_entities

Check here for details: https://github.com/pmazz/ps_hassio_entities#set-both-state-and-attributes

Or, in case you need to set the state only, your should use action: set_state. Then your code should be:

'1596141541557': alias: '###New Script Off' sequence:

  • data: action: set_state entity_id: binary_sensor.neo_coolcam_door_sensor state: 'off' service: python_script.hass_entities

Check here for this case: https://github.com/pmazz/ps_hassio_entities#set-state-only

Let me know if that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pmazz/ps_hassio_entities/issues/1#issuecomment-666742331, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH4BLR2TN4BYBRQN3POEY6DR6HXHNANCNFSM4POURLTA .

pmazz commented 4 years ago

👌