Display Oilfox Data

Sorry for the delay, oilfox is working fine now! :slight_smile:
Last question, do you have create a card with daily or weekly consumption?
Because I have build a daily consumption card with utility_meter, but my results are 0.
Is this because we have only one measurement per day?

Regards,

  Jurgen

I’m using only the cards as shown in previous posts.

Which card is that which are you using…

Show me the lovelace code and I will try to use it and fix it…

Hi kslb,

Here my configuration.yaml code for the utility_meter.

utility_meter:
  daily_energy:
    source: sensor.shelly_shplg_s_b52b76_total_consumption
    cycle: daily
  monthly_energy:
    source: sensor.shelly_shplg_s_b52b76_total_consumption
    cycle: monthly
    
  daily_energy_vaatwasser:
    source: sensor.shelly_shplg_s_e18b0f_total_consumption
    cycle: daily
  monthly_energy_vaatwasser:
    source: sensor.shelly_shplg_s_e18b0f_total_consumption
    cycle: monthly

### Mazout  
  daily_mazout:
    source: sensor.oilfox_trenutni_nivo_olja
    cycle: daily
  weekly_mazout:
    source: sensor.oilfox_trenutni_nivo_olja
    cycle: weekly
  monthly_mazout:
    source: sensor.oilfox_trenutni_nivo_olja
    cycle: monthly
  yearly_mazout:
    source: sensor.oilfox_trenutni_nivo_olja
    cycle: yearly

And here my card code!

type: horizontal-stack
title: Stookolie
cards:
  - type: entities
    entities:
      - entity: sensor.oilfox_trenutni_nivo_olja
        name: Inhoud
      - entity: sensor.daily_mazout
        name: Dagverbruik
        icon: 'mdi:hydraulic-oil-level'
      - entity: sensor.weekly_mazout
        icon: 'mdi:hydraulic-oil-level'
        name: Weekverbruik
      - entity: sensor.oilfox_stopnja_napolnjenosti
        name: Tankinhoud
      - entity: sensor.oilfox_visina_nivo_olja
        name: 'Tankinhoud '
        icon: 'mdi:counter'
      - entity: sensor.oilfox_stanje_baterije
        name: Batterij Meetsonde
    state_color: true
  - entity: sensor.oilfox_trenutni_nivo_olja
    font_size: 1em
    gauge:
      animatedValue: true
      borders: true
      colorNumbers: '#ccc'
      colorPlate: ''
      colorTitle: '#f5f5f5'
      colorUnits: '#f5f5f5'
      height: 240
      highlights:
        - color: brown
          from: 0
          to: 600
        - color: orange
          from: 600
          to: 1200
        - color: green
          from: 1200
          to: 3000
      majorTicks:
        - '0'
        - '300'
        - '600'
        - '900'
        - '1200'
        - '1500'
        - '1800'
        - '2100'
        - '2400'
        - '2700'
        - '3000'
      maxValue: 3000
      minValue: 0
      minorTicks: 10
      startAngle: 45
      strokeTicks: true
      sticksAngle: 270
      units: (L)
      type: radial-gauge
      valueBox: true
      valueDec: 1
      valueInt: 2
      width: 230
    type: 'custom:canvas-gauge-card'
  - entity: sensor.oilfox_stopnja_napolnjenosti
    font_size: 1em
    gauge:
      animatedValue: true
      borders: true
      colorNumbers: '#ccc'
      colorPlate: ''
      colorTitle: '#f5f5f5'
      colorUnits: '#f5f5f5'
      height: 240
      highlights:
        - color: brown
          from: 0
          to: 30
        - color: orange
          from: 20
          to: 40
        - color: green
          from: 40
          to: 100
      majorTicks:
        - '0'
        - '10'
        - '20'
        - '30'
        - '40'
        - '50'
        - '60'
        - '70'
        - '80'
        - '90'
        - '100'
      maxValue: 100
      minValue: 0
      minorTicks: 10
      startAngle: 45
      strokeTicks: true
      sticksAngle: 270
      units: (%)
      type: radial-gauge
      valueBox: true
      valueDec: 1
      valueInt: 2
      width: 230
    type: 'custom:canvas-gauge-card'
  - entity: sensor.oilfox_visina_nivo_olja
    font_size: 1em
    gauge:
      animatedValue: true
      borders: true
      colorNumbers: '#ccc'
      colorPlate: ''
      colorTitle: '#f5f5f5'
      colorUnits: '#f5f5f5'
      height: 240
      highlights:
        - color: gray
          from: 0
          to: 100
      majorTicks:
        - '0'
        - '10'
        - '20'
        - '30'
        - '40'
        - '50'
        - '60'
        - '70'
        - '80'
        - '90'
        - '100'
      maxValue: 100
      minValue: 0
      minorTicks: 10
      startAngle: 45
      strokeTicks: true
      sticksAngle: 270
      units: (cm)
      type: radial-gauge
      valueBox: true
      valueDec: 1
      valueInt: 2
      width: 230
    type: 'custom:canvas-gauge-card'

Thx,

Jurgen

FWIW - I could get the curl only working via:

token=`curl --silent -d '{"email":"EMAIL","password":"PASSWORD"}' -k 'https://api.oilfox.io/v3/login' -X POST -H 'Content-Type: application/json' | sed "s/{.*\"access_token\":\"\([^\"]*\).*}/\1/g"`;curl -H "Authorization: Bearer $token" -H "Connection: Keep-Alive" -H "User-Agent: HomeAssistant" -H "Content-Type: application/json" https://api.oilfox.io/v4/summary

How are the queries done in FLUX?

thanks for your work I’ve been using the workflow for 2 weeks but now I think they changed the Oilfox API: customer-api/docs/v1 at main · foxinsights/customer-api · GitHub

I’ve adjusted your workflow, it should work again now:
(Change
in “Login” → user, pw
and
in “Get Summary” → device-number (-> see Oilfox-App):

Also you need this node: node-red-contrib-http-request (node) - Node-RED

[{"id":"3079ee36.02c2d2","type":"tab","label":"Oilfox","disabled":false,"info":""},{"id":"a211bae9.c4bc88","type":"change","z":"3079ee36.02c2d2","name":"Befehl: Tokenabruf ","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"email\":\"xxxx\",\"password\":\"xxxxx\"}","tot":"json"},{"t":"set","p":"headers","pt":"msg","to":"{\"Content-Type\":\"application/json\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":40,"wires":[["a8d341648efcb13b"]]},{"id":"c376eaa0f7c9dc9f","type":"debug","z":"3079ee36.02c2d2","name":"curl","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":850,"y":40,"wires":[]},{"id":"e26c9ba4042d6762","type":"json","z":"3079ee36.02c2d2","name":"Token parsing","property":"payload","action":"","pretty":true,"x":140,"y":120,"wires":[["be5e9539112e31bc"]]},{"id":"4d3699a8c494fd22","type":"debug","z":"3079ee36.02c2d2","name":"Token","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":850,"y":120,"wires":[]},{"id":"be5e9539112e31bc","type":"change","z":"3079ee36.02c2d2","name":"Headers & Auth","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\t  \"Authorization\" : payload.token_type & \" \" & payload.access_token,\t  \"Content-Type\" : \"application/json\"\t}","tot":"jsonata"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":120,"wires":[["4d3699a8c494fd22","7a4956b43451d665"]]},{"id":"e90d148f71e213d8","type":"debug","z":"3079ee36.02c2d2","name":"Summary","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":860,"y":180,"wires":[]},{"id":"596c4fad6ca9bae1","type":"json","z":"3079ee36.02c2d2","name":"Summary parsing","property":"payload","action":"","pretty":true,"x":410,"y":180,"wires":[["e90d148f71e213d8","70ee284899ec8fbf","ec1a249b0e7cfca4"]]},{"id":"70ee284899ec8fbf","type":"ha-entity","z":"3079ee36.02c2d2","name":"OilFox Fill Percentage","server":"fbb2f3e2.d6216","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"OilFox Fill Percentage"},{"property":"device_class","value":"mdi:oil-level"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload.fillLevelPercent","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":640,"y":240,"wires":[["c952810034ee570c"]]},{"id":"c952810034ee570c","type":"debug","z":"3079ee36.02c2d2","name":"Entity Percent","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":880,"y":260,"wires":[]},{"id":"ec1a249b0e7cfca4","type":"ha-entity","z":"3079ee36.02c2d2","name":"OilFox_Fuellstand_heute","server":"fbb2f3e2.d6216","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"oilfox_fuellstand_heute"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"l"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload.fillLevelQuantity","stateType":"msg","attributes":[{"property":"letzteMessung","value":"payload.currentMeteringAt","valueType":"msg"},{"property":"naechsteMessung","value":"payload.nextMeteringAt","valueType":"msg"},{"property":"battery","value":"payload.batteryLevel","valueType":"msg"},{"property":"unit","value":"payload.quantityUnit","valueType":"msg"},{"property":"daysReach","value":"payload.daysReach","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":650,"y":320,"wires":[["b828611b0ad5db4d"]]},{"id":"b828611b0ad5db4d","type":"debug","z":"3079ee36.02c2d2","name":"Entity Liters","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":320,"wires":[]},{"id":"2852886dd0231d1a","type":"inject","z":"3079ee36.02c2d2","name":"00:05 Uhr","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"05 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":40,"wires":[["a211bae9.c4bc88"]]},{"id":"a8d341648efcb13b","type":"www-request","z":"3079ee36.02c2d2","name":"Login","method":"POST","ret":"txt","url":"https://api.oilfox.io/customer-api/v1/login","follow-redirects":true,"persistent-http":true,"tls":"","x":620,"y":40,"wires":[["c376eaa0f7c9dc9f","e26c9ba4042d6762"]]},{"id":"7a4956b43451d665","type":"www-request","z":"3079ee36.02c2d2","name":"Get Summary","method":"GET","ret":"txt","url":"https://api.oilfox.io/customer-api/v1/device/[xxxx]","follow-redirects":true,"persistent-http":true,"tls":"","x":140,"y":180,"wires":[["596c4fad6ca9bae1"]]},{"id":"fbb2f3e2.d6216","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

credits also goes to: Get Your Personal Oil Well Level – Integrating OilFox Into Home Assistant using node-red – MolesBlog

Any idea how to fix that?
slika

Did you use the flow I posted?
Did you change the device ID in “Get Summary” (URL: https://api.oilfox.io/customer-api/v1/device/[xxxx])?

Eh… sorry… I made a mistake… at device ID I wrote [ID], now I wrote withouth [ ] and it’s working…

But how to get data “battery level”, “oil level high” to home assistant…
I only get “oil level %” and “oil level L”

1 Like


In the screenshot you can see that I created the values ​​from the API as attributes. If you want to have them as states, you have to e.g. copy and adjust the “OilFox Fill Percentage” node:

I also looked for the “oil level high” but the API doesn’t provide it:

hwid string Hardware ID of the device
currentMeteringAt string RFC3339 timestamp
nextMeteringAt string RFC3339 timestamp
daysReach int, optional estimated days until the storage runs empty
validationError string, optional enum with errors regarding the measurement, see below
batteryLevel string, optional enum of the battery level, see below
fillLevelPercent int, optional fill level in %, 0-100
fillLevelQuantity int, optional fill level in kg or L
quantityUnit string unit of the fill level: kg or L

So, I think you have to calculate the hight like this (the hight of my tank is 119cm):

{% set t = states(‘sensor.oilfox_fill_percentage’) | int %}
{{ (t * 119) / 100 }}

put this tamplate to your configuration yaml:

template
  - sensor:
    - name: "oilfox_hight_level"
      state: 
          "{% set t = states('sensor.oilfox_fill_percentage') | int %}
           {{ (t * 119) / 100 }}"
      unit_of_measurement: "cm"
      unique_id: "12345678998765"

1 Like

This is strange, as before “Oil mesaurement level high” was available.

Marked with red:

the API-version before was not official!
now it is

Great… so this will be probably more pernament solution…

Thank you for everything…

Hi guy’s,

After the last HA update my Oilfox Node Red is not working anymore.
Can somebody maybe share his Node Red config again? :slight_smile:
And steps to taken to get it running?

Jurgen

just look at post no. 72

Hi Kitas,

Sorry, but can you point me to post 72?
Or is it possible to search the forum after specific post numbers?

I’m not a guru in this stuff! :wink:

Jurgen

sorry. it is 73…

Hi, I am having the same issue, but I am not sure where and what to change in the workflow. Maybe you could upload the “updated” workflow here so I could import it from scratch.
Thanks a lot!

Exactly this I’ve done in this post:

Copy the code and import it in nodered.
Then change user an pw (in Login-node) and the device-nr. (Get Summary-node).

Thanks a lot, didn’t see that before, it works now of course :wink:

1 Like