Display Oilfox Data

Sure, can check this evening

Ok I send you the info!

can you check my comand too? :slight_smile:

and can u PM me? Because thats my new account :frowning:

https://www.vseznalec.si/homeassistant/OilFox/
Username:
homeassistant
Password:
virtualclone2020_weeWX%

Lovelace

Node-RED

In above download link I publish:
flows.json
So you just change data and import it to Node-RED.

In flows.json change (with your data):
[email protected]
MYPASSWORD
192.168.1.2

After import change MQTT username/password based on your data in Mosquitto broker.
slika

slika

Also change timestamp (doubleclick) based on your needs… My OilFox sync with server every day at 17:45, so I’m checking data via cURL 20 minutes later at 18:05.

Sensor config:

#################################################################
# CISTERNA - OLJE (OilFox) via Node-RED
#################################################################

  - platform: mqtt
    name: "OilFox Trenutni nivo olja"
    state_topic: "OilFox"
    value_template: "{{ value_json.devices[0].metering.liters | int }}"
    icon: mdi:hydraulic-oil-level
    unit_of_measurement: L

  - platform: mqtt
    name: "OilFox Stopnja napolnjenosti"
    state_topic: "OilFox"
    value_template: "{{ value_json.devices[0].metering.fillingPercentage | int }}"
    icon: mdi:water-percent
    unit_of_measurement: '%'

  - platform: mqtt
    name: "OilFox Višina nivo olja"
    state_topic: "OilFox"
    value_template: "{{ value_json.devices[0].metering.currentOilHeight | int }}"
    icon: mdi:hydraulic-oil-level
    unit_of_measurement: cm

  - platform: mqtt
    name: "OilFox Stanje baterije"
    state_topic: "OilFox"
    value_template: "{{ value_json.devices[0].metering.battery | int }}"
    icon: mdi:car-battery
    unit_of_measurement: '%'

For lovelace you just take sensor names:
sensor.oilfox_trenutni_nivo_olja
sensor.oilfox_stopnja_napolnjenosti
sensor.oilfox_visina_nivo_olja
sensor.oilfox_stanje_baterije

And use it according to your need…

For communicating between HA and Node-RED I’m using MQTT broker:
slika

LOVELACE:

Use component: mini-graph-card

slika

cards: null
color_thresholds:
  - color: '#00C000'
    value: 2000
  - color: '#C0C000'
    value: 1000
  - color: '#C000C0'
    value: 500
entities:
  - entity: sensor.oilfox_trenutni_nivo_olja
hours_to_show: 744
icon: 'mdi:hydraulic-oil-level'
line_width: 2
name: 'Trenutni nivo olja (cisterna, zadnji mesec)'
show:
  labels: true
type: 'custom:mini-graph-card'
unit: litrov

slika

entities:
  - entity: sensor.oilfox_visina_nivo_olja
    index: 0
font_size: 75
hours_to_show: 744
icon: 'mdi:flash'
line_color: '#C000C0'
line_width: 2
name: Višina olja (zadnji mesec)
show:
  labels: true
type: 'custom:mini-graph-card'

slika

entity: sensor.oilfox_trenutni_nivo_olja
max: 1900
min: 0
name: Cisterna olja
severity:
  green: 1500
  red: 600
  yellow: 1100
type: gauge
unit: L

slika

type: gauge
entity: sensor.oilfox_stopnja_napolnjenosti
min: 0
max: 100
name: Stopnja napolnjenosti cisterne
severity:
  green: 80
  yellow: 60
  red: 40

slika

type: entity
entity: sensor.oilfox_stanje_baterije
name: Stanje baterije

slika

cards:
  - entities:
      - entity: sensor.oilfox_trenutni_nivo_olja
        index: 0
    font_size: 75
    hours_to_show: 72
    icon: 'mdi:flash'
    line_color: '#C000C0'
    line_width: 8
    name: Smer porabe
    show:
      labels: true
    type: 'custom:mini-graph-card'
  - entities:
      - entity: sensor.oilfox_trenutni_nivo_olja
        index: 0
    icon: 'mdi:flash'
    line_color: '#C00000'
    name: Dnevna poraba
    show:
      graph: bar
      labels: true
    type: 'custom:mini-graph-card'
type: horizontal-stack
1 Like

Hi, thanks for the great work! I struggle a bit in the setting for MQTT username/password, not really sure where I could find this setting. I have installed the MQTT-broker and it is up and running, but couldn’t find the settings in your post.

It works now, I have found the isssue, didn’t see where to change the settings in node-red :wink:
Everything is fine now, thanks for your great work!

Double click on last module “OilFox” and then you will find MQTT settings for IP on first screen and then under more settings you will find mqtt credentials…

1 Like

I updated flow, so that on Home Assistant start or restart automaticly try to get data from cURL.
All other settings stay the same.

Download link:
https://www.vseznalec.si/homeassistant/OilFox/
Username:
homeassistant
Password:
virtualclone2020_weeWX%

1 Like

Now - the next goal is that there will be button in HA which will check data from Node-red via MQTT in case of some fail in receiving data… In this case there would be no need to enter Node-Red and trigger MQTT action…

I updated my first initial post as both the Summary-URL after logging in and the JSON structure changed.

1 Like

I get error in importing Node-RED:

slika

Maybe there is problem with collation… I have unicode in Node-RED. Which one do you have?

Try to use paste/bin as this is good for share codes on-line withouth loosing and changing any posted data:
https://pastebin.pl/

Thank you…

https://pastebin.pl/view/5f163262 :slight_smile:

Thank you… now import is working… but now I got the new error:

The e-mail and PW was of course entered :slight_smile:

So, the problem is completly the same is in my modified flow (on which I send data directly to MQTT broker):

YOUR CODE:

10/23/2020, 7:27:47 PM[node: 8d4f499e.f83fb8](http://MYIP:8123/api/hassio_ingress/EWH0ShycRrxj6-LcrHdLxapt8JlZexUNzo7-4-zy_Z4/#)function : (error)
"TypeError: Cannot read property '0' of undefined"

MY CODE:

10/23/2020, 7:28:42 PMnode: parsingmsg : string[40]

“Unexpected token < in JSON at position 0”

So something is not correct regarding reading data and token or something… If I would know how to resolve it I already would.
The only help which I can do is to publish complete data sended from OilFox which can be analyzed via WireShark…

Well, that error message you receive was my reason to try and eventually come to the solution I updated here.
For me, it helped to attach the debug node at the first node and then getting onwards step by step.

Intresting…
With your code with debuging I get:


So, can you help me to extract the correct data?
Received data:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 724 0 667 100 57 1759 150 --:--:-- --:--:-- --:--:-- 1905 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 17 100 17 0 0 133 0 --:--:-- --:--:-- --:--:-- 133

Yea… I tried to debug and all this stuff but with no success… It seems that URL is not active anymore… or maybe there is some other mistake, do not know…
Completly stuck here…

Update… Now working again…
Yes. It now is another address to call…

[{"id":"6d24ab09.3de9e4","type":"exec","z":"3445fb7e.ef0b74","command":"","addpay":true,"append":"","useSpawn":"false","timer":"10","oldrc":false,"name":"cURL","x":530,"y":180,"wires":[["1abe4624.65c69a"],[],[]]},{"id":"d3ff7115.681c2","type":"inject","z":"3445fb7e.ef0b74","name":"13:00","repeat":"","crontab":"00 13 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":180,"wires":[["d88170cc.dd69a","9e7f94ce.0fbea8"]]},{"id":"d88170cc.dd69a","type":"change","z":"3445fb7e.ef0b74","name":"Befehl: Tokenabruf ","rules":[{"t":"set","p":"payload","pt":"msg","to":"curl -d '{\"email\":\"YOURMAIL\",\"password\":\"YOURPASSWORD\"}' -H \"Content-Type: application/json\" -H \"Connection: Keep-Alive\" -H \"User-Agent: HomeAssistant\" -X POST https://api.oilfox.io/v3/login ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":180,"wires":[["6d24ab09.3de9e4"]]},{"id":"1abe4624.65c69a","type":"json","z":"3445fb7e.ef0b74","name":"parsing","property":"payload","action":"","pretty":true,"x":680,"y":180,"wires":[["60a51545.d3e04c","145b44c6.1e4c3b"]]},{"id":"60a51545.d3e04c","type":"change","z":"3445fb7e.ef0b74","name":"Befehl: Datenabruf","rules":[{"t":"set","p":"payload","pt":"msg","to":"curl -H \"Content-Type: application/json\" -H \"Authorization: Bearer TOKEN\"  -X GET https://api.oilfox.io/v4/summary","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":180,"wires":[["1285d0d2.2af76f"]]},{"id":"1285d0d2.2af76f","type":"change","z":"3445fb7e.ef0b74","name":"füge Token ein","rules":[{"t":"change","p":"payload","pt":"msg","from":"TOKEN","fromt":"str","to":"Oilfox.Token","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":180,"wires":[["5bcab6c9.33fc18"]]},{"id":"2d089abf.23c3d6","type":"debug","z":"3445fb7e.ef0b74","name":"Füllgrad","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1960,"y":180,"wires":[]},{"id":"5bcab6c9.33fc18","type":"exec","z":"3445fb7e.ef0b74","command":"","addpay":true,"append":"","useSpawn":"false","timer":"10","oldrc":false,"name":"cURL","x":1250,"y":180,"wires":[["bcc77de6.f088c","ca623d68.b4c12"],[],[]]},{"id":"145b44c6.1e4c3b","type":"change","z":"3445fb7e.ef0b74","name":"Speichere Token","rules":[{"t":"set","p":"Oilfox.Token","pt":"flow","to":"payload.access_token","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":220,"wires":[[]]},{"id":"bcc77de6.f088c","type":"json","z":"3445fb7e.ef0b74","name":"parsing","property":"payload","action":"","pretty":true,"x":1400,"y":180,"wires":[["75d7a9bb.21b248","7ba91b65.f7ae34","27bac654.612c8a","224dd796.234648","1382a7c6.ba9718"]]},{"id":"75d7a9bb.21b248","type":"change","z":"3445fb7e.ef0b74","name":"Füllgrad","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.devices[0].lastMetering.fillingPercentage","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1600,"y":180,"wires":[["2d089abf.23c3d6"]]},{"id":"7ba91b65.f7ae34","type":"change","z":"3445fb7e.ef0b74","name":"Füllmenge","rules":[{"t":"set","p":"Oilfox_Füllmenge","pt":"flow","to":"payload.devices[0].lastMetering.liters","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload.devices[0].lastMetering.liters","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1610,"y":220,"wires":[["7f123e46.8488a","3166802d.bed52","5a4bf10f.f47ad"]]},{"id":"27bac654.612c8a","type":"change","z":"3445fb7e.ef0b74","name":"Batteriestatus","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.devices[0].lastMetering.battery","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":300,"wires":[["d989e9ec.398b88","39f87ac3.6764b6"]]},{"id":"7f123e46.8488a","type":"debug","z":"3445fb7e.ef0b74","name":"Füllmenge","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1970,"y":220,"wires":[]},{"id":"39f87ac3.6764b6","type":"debug","z":"3445fb7e.ef0b74","name":"Batteriestatus","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1980,"y":300,"wires":[]},{"id":"1ee6f4b0.fa3f9b","type":"influxdb out","z":"3445fb7e.ef0b74","influxdb":"65e36742.a95bb8","name":"Store","measurement":"Heizung_Oilfox_Füllgrad","precision":"","retentionPolicy":"","x":1810,"y":180,"wires":[]},{"id":"3166802d.bed52","type":"influxdb out","z":"3445fb7e.ef0b74","influxdb":"65e36742.a95bb8","name":"Store","measurement":"Heizung_Oilfox_Füllmenge","precision":"","retentionPolicy":"","x":1810,"y":220,"wires":[]},{"id":"d989e9ec.398b88","type":"influxdb out","z":"3445fb7e.ef0b74","influxdb":"65e36742.a95bb8","name":"Store","measurement":"Heizung_Oilfox_Batteriestatus","precision":"","retentionPolicy":"","x":1810,"y":300,"wires":[]},{"id":"224dd796.234648","type":"change","z":"3445fb7e.ef0b74","name":"Füllhöhe","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.devices[0].lastMetering.fillHeightCm","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1600,"y":260,"wires":[["7ff9a8d.6fe2058","63899d31.3833a4"]]},{"id":"63899d31.3833a4","type":"debug","z":"3445fb7e.ef0b74","name":"Füllhöhe","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1960,"y":260,"wires":[]},{"id":"7ff9a8d.6fe2058","type":"influxdb out","z":"3445fb7e.ef0b74","influxdb":"65e36742.a95bb8","name":"Store","measurement":"Heizung_Oilfox_Füllhöhe","precision":"","retentionPolicy":"","x":1810,"y":260,"wires":[]},{"id":"1382a7c6.ba9718","type":"switch","z":"3445fb7e.ef0b74","name":"Error?","property":"payload.errorCode","propertyType":"msg","rules":[{"t":"nnull"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":1590,"y":380,"wires":[["9a7622ff.4307","9758373f.d96708","c1365f8a.2f122"],[]]},{"id":"9a7622ff.4307","type":"change","z":"3445fb7e.ef0b74","name":"Fehlermeldung","rules":[{"t":"set","p":"payload","pt":"msg","to":"Oilfox hat einen Fehler","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1760,"y":380,"wires":[["92964e37.32895","f69a4925.e25ef8"]]},{"id":"92964e37.32895","type":"telegrambot-notify","z":"3445fb7e.ef0b74","name":"","bot":"836e221c.39211","chatId":"905598848","message":"","parseMode":"","x":1980,"y":380,"wires":[]},{"id":"9758373f.d96708","type":"change","z":"3445fb7e.ef0b74","name":"Fehlercode","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.errorCode","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1750,"y":420,"wires":[["92964e37.32895","f69a4925.e25ef8"]]},{"id":"c1365f8a.2f122","type":"delay","z":"3445fb7e.ef0b74","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"hours","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1760,"y":460,"wires":[["43936873.f996a8"]]},{"id":"bb3b9fda.f07d3","type":"link in","z":"3445fb7e.ef0b74","name":"Oilfox_Error","links":["43936873.f996a8"],"x":195,"y":140,"wires":[["d88170cc.dd69a"]]},{"id":"43936873.f996a8","type":"link out","z":"3445fb7e.ef0b74","name":"Oilfox_Error","links":["bb3b9fda.f07d3","8b1a05c5.263838"],"x":1915,"y":460,"wires":[]},{"id":"9e7f94ce.0fbea8","type":"change","z":"3445fb7e.ef0b74","name":"Füllmenge -> Gestern","rules":[{"t":"set","p":"Oilfox_Füllmenge_Gestern","pt":"flow","to":"Oilfox_Füllmenge","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":240,"wires":[["ddc88ab4.3e5428"]]},{"id":"5a4bf10f.f47ad","type":"function","z":"3445fb7e.ef0b74","name":"Verbrauch","func":"msg.payload = (flow.get(\"Oilfox_Füllmenge_Gestern\") - flow.get(\"Oilfox_Füllmenge\"));\n\nreturn msg ","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2170,"y":220,"wires":[["dd8d3633.94d6b8"]]},{"id":"dd8d3633.94d6b8","type":"influxdb out","z":"3445fb7e.ef0b74","influxdb":"65e36742.a95bb8","name":"Store","measurement":"Heizung_Oilfox_Verbrauch","precision":"","retentionPolicy":"","x":2330,"y":220,"wires":[]},{"id":"ddc88ab4.3e5428","type":"debug","z":"3445fb7e.ef0b74","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":240,"wires":[]},{"id":"6aa6f6d6.5bed88","type":"debug","z":"3445fb7e.ef0b74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":400,"wires":[]},{"id":"bd9ace16.2c38e","type":"inject","z":"3445fb7e.ef0b74","name":"Oilfox_Füllmenge","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Oilfox_Füllmenge","payloadType":"flow","x":260,"y":400,"wires":[["6aa6f6d6.5bed88"]]},{"id":"6d9db575.d62e4c","type":"comment","z":"3445fb7e.ef0b74","name":"Variablen Abfragen","info":"","x":210,"y":340,"wires":[]},{"id":"dd3df41a.9890c8","type":"debug","z":"3445fb7e.ef0b74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":440,"wires":[]},{"id":"c88ba4f0.8ef048","type":"inject","z":"3445fb7e.ef0b74","name":"Oilfox_Füllmenge_Gestern","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Oilfox_Füllmenge_Gestern","payloadType":"flow","x":290,"y":440,"wires":[["dd3df41a.9890c8"]]},{"id":"ca623d68.b4c12","type":"switch","z":"3445fb7e.ef0b74","name":"Error?","property":"payload.errorCode","propertyType":"msg","rules":[{"t":"cont","v":"Unexpected","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1390,"y":220,"wires":[["9a7622ff.4307"]]},{"id":"f69a4925.e25ef8","type":"debug","z":"3445fb7e.ef0b74","name":"Fehlercode","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1970,"y":420,"wires":[]},{"id":"65e36742.a95bb8","type":"influxdb","z":"","hostname":"10.0.1.2","port":"8086","protocol":"http","database":"Data","name":"InfluxData","usetls":false,"tls":""},{"id":"836e221c.39211","type":"telegrambot-config","z":"","botname":"HnCHomeBot","usernames":"","chatIds":"905598848","pollInterval":"20"}]