pmazz / ps_hassio_entities

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

the script doesn't seem to run properly not catching the parameter "action" #2

Closed KonTiki1957 closed 3 years ago

KonTiki1957 commented 3 years ago

I'm interested in using this script but I'm not succeeding, I always get the following error: [homeassistant.components.python_script.hass_entities.py] Required parameter 'action' is missing. with following HA script configuration. Can you give me a hint? Thank you.

YAML configuration

prova_python_script:
  alias: prova python script
  sequence:
  - service: python_script.hass_entities
    data:
      service_data:
        action: set_state
        entity_id: sensor.temperatura_piano_sopra
        state: 30
        log_enabled: true
  mode: single

Screenshots If applicable, add your screenshots here.

Version latest Additional information Add any other relevant additional information here.

pmazz commented 3 years ago

I'm afraid your code is not correct. There's no need of the service_data level. Just put action, entity_id and state below data:.

This should work:

prova_python_script:
  alias: prova python script
  sequence:
  - service: python_script.hass_entities
    data:
      action: set_state
      entity_id: sensor.temperatura_piano_sopra
      state: 30
      log_enabled: true
  mode: single

Let me know if that helps.

vicentecandido commented 3 years ago

@pmazz I used your code, but it returns to old state after few seconds.

My code: `monitor_4k_state_off: sequence:

pmazz commented 3 years ago

@vicentecandido Your script seems to only alter the switch state. Since you're not actually "switching off" the switch, its state is reverted back by home assistant after few seconds. This is not a proper use of the script. You should use the switch.turn_off service instead. https://www.home-assistant.io/integrations/switch/#use-the-services

vicentecandido commented 3 years ago

@pmazz Thanks to help me. I need of a script alter only state without executing the action.