Help with RESTful Sensor(s) please

I am struggling with the learning curve with monitoring / configuring my AC unit using its RESTful interface. Having spent some time sniffing the traffic between the vendors phone app and their web API, I now understand how to interpret the AC’s status and how to change settings. I would now like to add some state information to HA and then add some controls. However, I am stuck on the best approach for doing so.

I have created a RESTful sensor:

 - platform: rest
    name: InnovaAC
    resource: http://cloud/api/v/1/status
    headers:
      X-serial: 
      X-UID: 
      X-Requested-With: XMLHttpRequest
      Content-Type: application/json
      User-Agent: HomeAssistantRESTsensor
    json_attributes:
    - RESULT
    value_template: '{{ value_json.value }}'

If I then put this: “{{ states.sensor.innovaac.attributes }}” into the HA template editor, I can see the following returned:

{'RESULT': {'sp': 23, 'wm': 1, 'ps': 0, 'fs': 0, 'fr': 0, 'cm': 0, 'a': [], 't': 24, 'cp': 0, 'of': 0, 'nm': 0, 'ns': 0, 'ncc': 232, 'ccv': 1, 'uptime': 147380, 'majorVersion': 1, 'minorVersion': 0, 'buildVersion': 36, 'heatingDisabled': 0, 'coolingDisabled': 0, 'hotelMode': 0, 'kl': 0, 'heatingResistance': 0}, 'friendly_name': 'InnovaAC'}

What I need to figure out is how to capture some of these values. For example, ‘sp’ is the temperature set point. But I can’t get this data point.

Once that (hopefully) simple element is working, I then need to take a value like ‘cm’ and if it is 0 have a state of “Manual” and if 1 have “Scheduling”. ‘wm’ has 6 different possible values.

Any and all pointers gratefully received at this point!

The full returned JSON from the call is:

{"success":true,"sw":{"V":"1.0.36"},"UID":"00:00:00:00:00:00","setup":{"serial":"00000000","name":"Shed"},"net":{"ip":"0.0.0.0","sub":"","gw":""},"RESULT":{"sp":23,"wm":1,"ps":0,"fs":0,"fr":0,"cm":0,"a":[],"t":24,"cp":0,"of":0,"nm":0,"ns":0,"ncc":232,"ccv":1,"uptime":147690,"majorVersion":1,"minorVersion":0,"buildVersion":36,"heatingDisabled":0,"coolingDisabled":0,"hotelMode":0,"kl":0,"heatingResistance":0},"time":{"d":"07","m":"09","y":"2018","h":"15","i":"56"}}

Seems like you need to create some template sensors for each attribute you want to monitor. Can you access ‘set point’ with {{ states.sensor.innovaac.attributes.RESULT.sp }} ?

It seems like you are really close!

That was indeed it! Thank you!

So now I have the following:

  shed_ac_set_point:
    friendly_name: "Shed AC Set"
    unit_of_measurement: '°C'
    value_template: '{{ states.sensor.innovaac.attributes.RESULT.sp }}'
  innova_ac_mode_num:
    value_template: '{{ states.sensor.innovaac.attributes.RESULT.wm }}'
  innova_ac_power_num:
    value_template: '{{ states.sensor.innovaac.attributes.RESULT.ps }}'
  shed_ac_mode:
    friendly_name: "Shed AC Mode"
    value_template: >-
      {%- if is_state("sensor.innova_ac_power_num", "0") %}
          Off
      {%- elif is_state("sensor.innova_ac_mode_num", "0") %}
          Heat
      {%- elif is_state("sensor.innova_ac_mode_num", "1") %}
          Cool
      {%- elif is_state("sensor.innova_ac_mode_num", "3") %}
          Dry
      {%- elif is_state("sensor.innova_ac_mode_num", "4") %}
          Fan
      {%- elif is_state("sensor.innova_ac_mode_num", "5") %}
          Auto
      {% else %}
          Unknown
      {%- endif %}

Which works but doesn’t seem very efficient. I’d prefer not to create the innova_ac_*_num sensors which I only use in the “if / elif / else / endif” block. Is it possible to directly reference the values in sensor.innovaac.attributes?

Possibly writing a custom component that does all the data gathering and presents as a climate component?

@jonboy I have the same AC make, I just found out how to read out the values, but have you been able to also write values, like set a temperature, or switch on/off etc?
I would really appreciate some help here.
Thank you very much!
cheers

As per my earlier post, reading values works fine by looking at the response from the manufacturer’s web service. I do find that their web service is pretty unreliable and this is where my current approach to integration falls down. When the service doesn’t give a sensible response, I have issues.

First question I have is: are you using the manufacturer’s web service? (I’d much prefer to find a local interface of some sort!)

You can post to the web service to control the a/c (when the web service is behaving) e.g.

TURN OFF
innova_setmode_off: "curl --header 'X-serial: INxxxxxxx' --header 'X-UID: 00:00:00:00:00:00' --header 'X-Requested-With: XMLHttpRequest' -X POST http://innovaenergie.cloud/api/v/1/power/off"

TURN ON
innova_setmode_on: "curl --header 'X-serial: INxxxxxxx' --header 'X-UID: 00:00:00:00:00:00' --header 'X-Requested-With: XMLHttpRequest' -X POST http://innovaenergie.cloud/api/v/1/power/on"

Cool, thanks, I have not been able to figure THAT out.
Regarding web service:
I am accessing the local IP of the device on port 80 which actually works quite good, even though my wifi is weak where the device is located.

Now I feel quite silly. Pretty sure I’d tried sniffing the local IP address and got nowhere. So I have now tried pretty similar commands against the local IP and they work fine so far:

  innova_setpoint: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp={{states.input_number.innova_inputsettemp.state}}' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_16: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=16' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_17: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=17' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_18: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=18' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_19: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=19' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_20: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=20' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_21: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=21' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_22: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=22' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_23: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=23' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_24: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=24' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_25: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=25' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_26: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=26' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_27: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=27' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setpoint_28: "curl --header 'X-Requested-With: XMLHttpRequest' --data 'p_temp=28' http://1.2.3.4/api/v/1/set/setpoint"
  innova_setmode_on: "curl --header 'X-Requested-With: XMLHttpRequest' -X POST http://1.2.3.4/api/v/1/power/on"
  innova_setmode_off: "curl --header 'X-Requested-With: XMLHttpRequest' -X POST http://1.2.3.4/api/v/1/power/off"
  innova_setmode_heat: "curl --header 'X-Requested-With: XMLHttpRequest' -X POST http://1.2.3.4/api/v/1/set/mode/heating"
  innova_setmode_cool: "curl --header 'X-Requested-With: XMLHttpRequest' -X POST http://1.2.3.4/api/v/1/set/mode/cooling"
  innova_setmode_dry: "curl --header 'X-Requested-With: XMLHttpRequest' -X POST http://1.2.3.4/api/v/1/set/mode/drying"
  innova_setmode_fan: "curl --header 'X-Requested-With: XMLHttpRequest' -X POST http://1.2.3.4/api/v/1/set/mode/fanonly"
  innova_setmode_auto: "curl --header 'X-Requested-With: XMLHttpRequest' -X POST http://1.2.3.4/api/v/1/set/mode/auto"

Hi, a bit late to the party, but just so you know, I have recently created a custom climate component for the innova 2.0 AC unit.

It can be installed through HACS.