cathiele / homeassistant-goecharger

Home Assistant custom_component for controlling the go-eCharger EV-Charger
MIT License
89 stars 29 forks source link

State changes through REST on switch.goecharger_00xxxx_allow_charging not working #19

Closed pkret closed 4 years ago

pkret commented 4 years ago

I am unable to activate/deactivate the charger through the home assistant rest api:

POST http://home.local/api/states/switch.goecharger_00xxxx_allow_charging {"state":"on"}

{
    "attributes": {},
    "context": {
        "id": "d0d971e0605543adaa80ddda2b4e6406",
        "parent_id": null,
        "user_id": "d6608a685bca4227b5a5e0ec3514f679"
    },
    "entity_id": "switch.goecharger_00xxxx_allow_charging",
    "last_changed": "2020-07-11T15:58:40.274992+00:00",
    "last_updated": "2020-07-11T15:58:40.274992+00:00",
    "state": "on"
}

Will trigger the switch within home assistant itself on, but only until the next update of the component when it is flipped back to off, the charger itself will remain off for the whole time. Triggering the state change though the development tab will also show similar behaviour.

Doing a GET http://goe.local/mqtt?payload=alw=1 is successful. Also, if i create this directly in the config:

rest_command:
  goe_on:
    url: 'http://goe.local/mqtt?payload=alw=1'
  goe_off:
    url: 'http://goe.local/mqtt?payload=alw=0'

switch:
  - platform: template
    switches:
      goe_charger_activate:
        friendly_name: "Activate"
        value_template: "{{ is_state('sensor.charger_unlocked', '1') }}"
        turn_on:
          service: rest_command.goe_on
        turn_off:
          service: rest_command.goe_off

Then this will successfully and permanently switch on the charger: POST http://home.local/api/states/switch.goe_charger_activate {"state":"on"}

Unfortunately I don't know enough python and custom components to check what's wrong in the component...

cathiele commented 4 years ago

As far as i know the api/states-endpoint just changes the home-assistant representation of the Entity without affecting the real device.

Please try:

POST http://home.local/api/services/switch/turn_on
{"entity_id": "switch.goecharger_00xxxx_allow_charging"}

or

POST http://home.local/api/services/switch/turn_off
{"entity_id": "switch.goecharger_00xxxx_allow_charging"}
pkret commented 4 years ago

Thanks for your help, i did not know that. Your examples did work!