Sensor to read from URL?

Hi,

I have a Daikin HVAC that I can’t integrate into HASS, but after som research I found out that it give me atleast some info with a URL. The problem now is that I can’t find out how to read/parse the info and turn it into a sensor.
If I type http://daikin-ip/aircon/get_sensor_info into a browser I get this:
ret=OK,htemp=24.0,hhum=-,otemp=8.0,err=0,cmpfreq=14

htemp is my indoor temp and otemp is my outdoor temp.

Is it possible to present htemp and otemp as a sensor from that URL?

I haven’t tried it with a non-JSON sensor, but the place you’ll want to start is here:

Experiment with what you get in the states panel. If you get a state of something like “ret=OK,htemp=24.0,hhum=-,otemp=8.0,err=0,cmpfreq=14”, you might be able to do some parsing with templates.

Use the template dev tool to experiment with parsing the returned data.

If the data is HTML then as a last resort the scrape sensor could help.

1 Like

Thanks! Will Try these alternatives.

The Domoticz json api isn’t easy to her values from… I tried different ways, but i can’t get it to work. I see that there is a guy with the same problem as mine here:

Any ideas?

Hi, yes. Try jq Parsing JSON…
sudo apt-get install jq

https://stedolan.github.io/jq/manual/

Seems like you have the european wifi module

There is more discussion in a different topic:

I suggested making an integration for it (not skyfi but the EU one) there, I also made one for Domoticz (I used that before I switched to HAS).

I realize it’s an old thread, but I am trying to understand the relevance of piffmasta’s comment here. I want to bring data from a json entity via a url into an HA sensor. Ideally I would filter it in jq before I bring it in – it works very nicely from the command line with cURL and jq.

I’ve googled, but have not seen anything. Is there a way to use jq within HA?

cheers,
Sean

Sorry, I think I missunderstood this, I was using a commandline Sensor to parse values from curl with jq like you did.

oh, ok, that makes sense. And how do you bring the data into HA?

like this…

  allnet:
     command_on: 'curl -L "http://172.27.101.51/xml/jsonswitch.php?id=1&set=1"'
     command_off: 'curl -L "http://172.27.101.51/xml/jsonswitch.php?id=1&set=0"'
     command_state: 'curl -sb -L "http://172.27.101.51/xml/jsonswitch.php?id=1" | jq .result.status'
     value_template: '{{ value == "1" }}'

the curl command gives me: {“result”:{“id”:“1”,“error”:0,“status”:0}}
and I’d like to know the status (On or Off) -> so " | jq …"

then I’ll get 0 or 1
you can use then value_templates…

another sensor:
sonoffs20_state: ‘curl -sb -L “http://ipadress/cm?&user=username&password=password&cmnd=Power” | jq -r .POWER’
gives me ON or OFF -> this can be directly used, without value_template…

hope this helps

Thanks, I’ll give it a try.

Hi piff,

It worked perfectly. I wasn’t aware of command_line, thanks for your help.

  - platform: command_line
    name: '24H rain'
    command: "curl -s https://api.buienradar.nl/data/public/2.0/jsonfeed | jq '.actual.stationmeasurements[] | select(.stationid == 6375) | .rainFallLast24Hour'"
    unit_of_measurement: 'mm'
    # value_template: '{{ value | multiply(1000) | round(0) }}' # Not sure if in cm or mm.
    scan_interval: 3600

cheers,
Sean

guys, i see you are working with the JQ command -)

can you help me with my first question here.? i think i need the same, just dont know how i need to put the JQ in my command line

command: (echo ‘{“cmd”:“listactions”}’; sleep 1) | nc XXXX 8000 | jq ‘.id .value1’

something like that i need? to get .id and .value1 from the data array