Http Binding to get Renault Zoe status

Where have you entered the remaining ones from the former items file

Switch ZOE_charge_start "Laden starten []"
Switch ZOE_ac_start "Klimatisierung starten []"
Switch ZOE_ac_start_calendar
Switch ZOE_Home "Standort [MAP(zoe.map):%s]" <location>
Switch Zoe_Alexa_Routine "ZOE Routine" { alexa="PowerController.powerState" }
Switch ZOE_charge100 "Batterie 100% laden[]"
Location ZOE_coordinates "Koordinaten" <location>

in the http binding as channel as well or in the new items file like this one:

Number ZOE_actual_km "Kilometer [%s km]" <km>  { channel="http:url:zoe:actual_km" }
String ZOE_plug_connected "An Ladesäule? [%s]" <wallbox>  { channel="http:url:zoe:plug_connected" }
String ZOE_charge_end "Ladungsende [%s h]" <finish>     { channel="http:url:zoe:charge_end" }
String ZOE_charging "Wird geladen? [%s]" <strom>        { channel="http:url:zoe:charging" }
Number ZOE_current_battery "Akkustand [%s %%]" <battery>        { channel="http:url:zoe:current_battery" }
Number ZOE_energy "Energie [%s kWh]" <energy>   { channel="http:url:zoe:energy" }
Number ZOE_distance "Reichweite [%s km]" <entfernung>   { channel="http:url:zoe:distance" }
String ZOE_status_update "Status vom [%s]" <time>       { channel="http:url:zoe:status_update" }
Number ZOE_position_north "Position Nord [%s]"  { channel="http:url:zoe:position_north" }
Number ZOE_position_east "Position Ost [%s]"  { channel="http:url:zoe:position_east" }
String ZOE_position_update "Position vom [%s]" <time> { channel="http:url:zoe:position_update" }
Switch ZOE_charge_start "Laden starten []"
Switch ZOE_ac_start "Klimatisierung starten []"
Switch ZOE_ac_start_calendar
Switch ZOE_Home "Standort [MAP(zoe.map):%s]" <location>
Switch Zoe_Alexa_Routine "ZOE Routine" { alexa="PowerController.powerState" }
Switch ZOE_charge100 "Batterie 100% laden[]"
Location ZOE_coordinates "Koordinaten" <location>

as I’m getting the following errors in the log:

2021-09-16 09:39:50.866 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'zoe.items'
2021-09-16 09:39:51.111 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'zoe-5' failed: The name 'ZOE_current_battery' cannot be resolved to an item or type; line 54, column 7, length 19 in zoe
2021-09-16 09:39:51.266 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'switchoffwallboxzoe-1' failed: The name 'ZOE_charge100' cannot be resolved to an item or type; line 5, column 7, length 13 in switchoffwallboxzoe
2021-09-16 09:39:51.269 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'zoe-3' failed: The name 'ZOE_position_north' cannot be resolved to an item or type; line 28, column 65, length 18 in zoe
2021-09-16 09:39:51.275 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'zoe-3' failed: The name 'ZOE_position_north' cannot be resolved to an item or type; line 28, column 65, length 18 in zoe
2021-09-16 09:39:52.116 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'zoe.items'
2021-09-16 09:39:52.220 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'zoe-5' failed: The name 'ZOE_current_battery' cannot be resolved to an item or type; line 54, column 7, length 19 in zoe
2021-09-16 09:40:00.199 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'zoe-4' failed: The name 'ZOE_distance' cannot be resolved to an item or type; line 42, column 8, length 12 in zoe
2021-09-16 09:40:24.026 [WARN ] [p.internal.http.HttpResponseListener] - Requesting 'http://10.0.1.46/zoe/index.php' (method='GET', content='null') failed: Total timeout 3000 ms elapsed
2021-09-16 09:42:03.710 [INFO ] [nding.http.internal.HttpThingHandler] - Using the secure client for thing 'http:url:zoe'.

Items without channels stay the same as before.
Your errors indicate that your items cannot be found.
If you want to use my definitions, you need to name your thing in a proper way:

If you are sure your definitions are correct, restart openHAB. Sometimes this solves similar problems.

follwing error:

2021-09-16 13:07:41.622 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'zoe-1' failed: An error occurred during the script execution: array element type mismatch in zoe

code for rule:

// Triggers:
// - When ZOE_ac_start received command ON

// context: zoe-1
var String URL = 'http://myhome/zoe/index.php?acnow'
val String curlcommand = "curl@@-d@@" + "@@POST@@" + URL +"@@-H@@Content-Type:application/json@@-H@@accept"
var String jsonacnow = executeCommandLine(curlcommand, 1000)

Is the Syntax still right for OH3?

//Authorization Header for Basic Authentication: https://www.base64encode.org/
var Boolean MessageB = false

rule "Klimatisierung starten"
when
        Item ZOE_ac_start received command ON
then
    var String URL = 'http://10.0.1.46/zoe/index.php?acnow'
    val String curlcommand = "curl@@-d@@" + "@@POST@@" + URL +"@@-H@@Content-Type:application/json@@-H@@accept"
    var String jsonacnow = executeCommandLine(curlcommand, 1000) //executes the curl-string
end

rule "Laden starten"
when
        Item ZOE_charge_start received command ON
then
    var String URL = 'http://10.0.1.46/zoe/index.php?chargenow'
    val String curlcommand = "curl@@-d@@" + "@@POST@@" + URL +"@@-H@@Content-Type:application/json@@-H@@accept"
    var String jsoncharge = executeCommandLine(curlcommand, 1000) //executes the curl-string
end

rule "Zoe Home"
when
    Item ZOE_position_north changed  or
    Item ZOE_position_east changed
then
    val PointType home_location  = new PointType(new DecimalType(47.215), new DecimalType(9.703)) //hier die Koordinaten deines Standortes eintragen
    val PointType Zoe_location  = new PointType(new DecimalType(ZOE_position_north.state.toString), new DecimalType(ZOE_position_east.state.toString))
    val int distance = Zoe_location.distanceFrom(home_location).intValue()
    ZOE_coordinates.postUpdate(Zoe_location) //Update für Mapview
    if ( distance < 50) { //Abstand in Metern vom Standort
        ZOE_Home.postUpdate(ON)
    } else {
        ZOE_Home.postUpdate(OFF)
    }
end

no.
E.g. syntax of executeCommandLine has changed see Actions | openHAB

Ok, thanks

Not sure if I get this done by myself.

executeCommandLine(Duration.ofSeconds(5), "curl","-d","POST","https://zoe.yxyxyxyxyx.net/?acnow","-H","Content-Type:application/json","-s","-H","authorization:Basic abababababaabababa")

Of course you need to adapt the url and the authorization code (base64)

As you can see, it is all easier now with openHAB3 :slight_smile:

Not sure if the command is right, as the car is doing nothing

// Triggers:
// - When ZOE_ac_start received command ON

// context: zoe-1
executeCommandLine(Duration.ofSeconds(5), "curl","-d","POST","http://10.0.1.46/zoe/index.php?acnow","-H","Content-Type:application/json","-s","-H")

The Renault API server had a lot of issues in the last few days, maybe it is down again. I tested my ZOE a few minutes ago and it did nothing, too.

Usually you don’t have to call the index.php, just call the ?acnow command.

Always check the Renault App first for testing: if the app does nothing, the script can’t work as it is using the same api calls.

Edit: also you have commented out the trigger, so this won’t work in either case :slight_smile:

The input from the rules file looks like this:

rule "Klimatisierung starten"
when
Item ZOE_ac_start received command ON
then
executeCommandLine(Duration.ofSeconds(5), "curl","-d","POST","http://10.0.1.46/zoe/index.php?acnow","-H","Content-Type:application/json","-s","-H")
end

in the web gui under rules it is shown as this:

// Triggers:
// - When ZOE_ac_start received command ON

// context: zoe-1
executeCommandLine(Duration.ofSeconds(5), "curl","-d","POST","http://10.0.1.46/zoe/index.php?acnow","-H","Content-Type:application/json","-s","-H")

bug?

You’re right, the trigger is not working therefore?

I don’t know, put a logInfo in the then part to find out.

LogInfo entry not in the logfile, therefore trigger is not working…
strange. right in the rules file, but wrong in the gui and not working

All you need is a switch and a simple rule:

Switch ZOE_ac_start "Klimatisierung starten []"

rule "Klimatisierung starten"
when
	Item ZOE_ac_start received command ON
then
    executeCommandLine(Duration.ofSeconds(5), "curl","-d","POST","https://zoe.yxyxyxyxyxyxy.net/?acnow","-H","Content-Type:application/json","-s","-H","authorization:Basic ababababababababab")
end

Again, the Renault servers have issues sometimes, it may not work for a couple of days and always check the MyRenailt App first before doing some testing in openHAB.

Something seems to be different in OH3.

When I enter the rule by hand in GUI, the Code looks like

triggers:
  - id: "1"
    configuration:
      itemName: ZOE_ac_start
      command: ON
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >-
        executeCommandLine(Duration.ofSeconds(5),
        "curl","-d","POST","http://10.0.1.46/zoe/index.php?acnow","-H","Content-Type:application/json","-s","-H")

    type: script.ScriptAction

but is also not being triggered by the button.

but I will keep looking into it. The renault app is responding, the ac start can be triggered by app, wich let me assume that script is not working.

After rebooting the PI and the openhab service, I’m getting the following error in the log (for the rule in the rules file from you)

2021-09-17 09:49:03.107 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'zoe-1' failed: An error occurred during the script execution: index=1, size=1 in zoe

same for the next rule

2021-09-17 09:50:00.662 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'zoe-4' failed: An error occurred during the script execution: Couldn't invoke 'assignValueTo' for feature JvmVoid:  (eProxyURI: zoe.rules#|::0.2.3.2.0.1.0.0::0::/1) in zoe

everything seems very different

Just use a rules file like in openHAB2.
If you want to use MainUI to create the rules, then yes, it is different.

Ok, thanks

Ii tested again this morning, the Renault servers seem to be working again, and the rule from above

worked fine.

for me as well, thanks for your support. Now it’s working flawlessly.
… but there is a bug as you mentioned. after changing the rules you need to restart openhab, not everytime the rule change will be successfully activated

I would not call this a bug: only in rare instances openHAB needs to be restarted to pick up changes, mostly if item names are changed.