Configuring http remote logging to Home Assistant
Recently setup BrewPiLess on a Sonoff Basic R2 and got an iSpindel working with it. I'm trying to enable remote logging to my Home Assistant setup.
It should be possible to simply create a "Long-lived token" and let BrewPiLess post a json formatted message to the API which should then create the entities.
Creating the token is fairly easy, but how to make BrewPiLess "consume" it?
According to the docs it should be possible to dousing curl: https://developers.home-assistant.io/docs/api/rest
I tried running:
curl -X GET -H "Authorization: Bearer MYSECRETTOKEN" -H "Content-Type: application/json" http://HA_IP:8123/ENDPOINT
from BPL_IP/testcmd.htm but it didn't seem to do anything.
Any suggestions on consuming the token?
Should I simply do it from another machine and upload it to the BPL filesystem somehow?
Afterwards - could the remote logging look something like this perhaps?

My suggestion for you is create a bridge using node red.
BPLess sends its data to a "http in" node on Node Red that will redirect it to Home Assistant.
My suggestion for you is create a bridge using node red.
BPLess sends its data to a "http in" node on Node Red that will redirect it to Home Assistant.
Sounds neat... if only I had a clue how to get started :) I'm running Home Assistant in Docker, so the logical thing would probably be to create a node-red instance in docker as well. Will give it a try - but some pointers would be greatly appreciated.
I use HassIO, so I just installed Node Red as a Home Assistant add on. Just one click solved the problem. I'm not familiar with containers.
okay.. starting node-red was fairly easy. Now - setting it up will be the fun part ;) Would it be possible for you to share your node-red flow, and BPLess logging configuration?
Sorry, I don't have this feature. It was just an idea for you.
The fist step is using a http in node, connect a debug node to its output and make the brewpiless send data to it.
Okay - this is basically too easy!
I went with MQTT as the link to HA since I use that for just about everything else.
BPL logging configured like this:

My node-red looks like this (UPDATED as shown below):

And MQTT messages flowing in (ESP sensor just to get a feel for the flow ;) ):
/homeassist/ESP_Kontor/Lux 67 /homeassist/ESP_Kontor/Temperature 27.17 /homeassist/ESP_Kontor/Humidity 32.45 /homeassist/ESP_Kontor/Pressure 1018.82 /homeassist/bpl/ fridgetemp 28.4 /homeassist/bpl/ gravity 1.1198 /homeassist/bpl/ istemp 28.9 /homeassist/bpl/ isvolt 4.1
Now I just need to figure out how to get rid of the space between the topic and message (maybe not important, but still - UPDATE: super important! see solution below) and create the sensors and HA config :)
UPDATE: 2020-10-14 - Got it all wrong, but the updated flow below actually works - splits the message and directs to indivual topics for each value.
If anybody should be interested, my node-red flow can be used:
[{"id":"2999551d.7fb5c2","type":"tab","label":"BrewPiLess to MQTT","disabled":false,"info":""},{"id":"e4040b7c.00ec9","type":"http in","z":"2999551d.7fb5c2","name":"brewpiless remote log","url":"/bpl","method":"post","upload":false,"swaggerDoc":"","x":140,"y":500,"wires":[["dc49b557.0f4e58"]]},{"id":"dc49b557.0f4e58","type":"split","z":"2999551d.7fb5c2","name":"","splt":"&","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":370,"y":500,"wires":[["f81e004f.4c9e","b39d20aa.d6b14","7c3028a0.882408","14d1c0a3.d1a227","69a1088e.b32bf8"]]},{"id":"8d768fce.022548","type":"change","z":"2999551d.7fb5c2","name":"fridgetemp","rules":[{"t":"change","p":"payload","pt":"msg","from":"fridgetemp ","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":400,"wires":[["4595648.aa7709c"]]},{"id":"f0f6e960.317648","type":"change","z":"2999551d.7fb5c2","name":"gravity ","rules":[{"t":"change","p":"payload","pt":"msg","from":"gravity ","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":460,"wires":[["a0733803.674b3"]]},{"id":"3b1e2737.339e1","type":"change","z":"2999551d.7fb5c2","name":"istemp ","rules":[{"t":"change","p":"payload","pt":"msg","from":"istemp ","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":520,"wires":[["b9c4f4c5.db46d"]]},{"id":"1ab1d6ce.8c13d9","type":"change","z":"2999551d.7fb5c2","name":"isvolt ","rules":[{"t":"change","p":"payload","pt":"msg","from":"isvolt ","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":580,"wires":[["bfd900aa.96a5d8"]]},{"id":"4595648.aa7709c","type":"mqtt out","z":"2999551d.7fb5c2","name":"/homeassist/bpl/fridgetemp","topic":"/homeassist/bpl/fridgetemp","qos":"","retain":"","broker":"2229fbd.cac8d84","x":1180,"y":400,"wires":[]},{"id":"a0733803.674b3","type":"mqtt out","z":"2999551d.7fb5c2","name":"/homeassist/bpl/gravity","topic":"/homeassist/bpl/gravity","qos":"","retain":"","broker":"2229fbd.cac8d84","x":1170,"y":460,"wires":[]},{"id":"b9c4f4c5.db46d","type":"mqtt out","z":"2999551d.7fb5c2","name":"/homeassist/bpl/istemp","topic":"/homeassist/bpl/istemp","qos":"","retain":"","broker":"2229fbd.cac8d84","x":1160,"y":520,"wires":[]},{"id":"bfd900aa.96a5d8","type":"mqtt out","z":"2999551d.7fb5c2","name":"/homeassist/bpl/isvolt","topic":"/homeassist/bpl/isvolt","qos":"","retain":"","broker":"2229fbd.cac8d84","x":1160,"y":580,"wires":[]},{"id":"46dc1d0d.19c0a4","type":"change","z":"2999551d.7fb5c2","name":"isseen ","rules":[{"t":"change","p":"payload","pt":"msg","from":"isseen ","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":640,"wires":[["c6e67d4.ec8d1"]]},{"id":"c6e67d4.ec8d1","type":"mqtt out","z":"2999551d.7fb5c2","name":"/homeassist/bpl/isseen","topic":"/homeassist/bpl/isseen","qos":"","retain":"","broker":"2229fbd.cac8d84","x":1160,"y":640,"wires":[]},{"id":"f81e004f.4c9e","type":"switch","z":"2999551d.7fb5c2","name":"fridgetemp","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"fridgetemp ","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":690,"y":400,"wires":[["8d768fce.022548"]]},{"id":"b39d20aa.d6b14","type":"switch","z":"2999551d.7fb5c2","name":"gravity","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"gravity ","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":460,"wires":[["f0f6e960.317648"]]},{"id":"7c3028a0.882408","type":"switch","z":"2999551d.7fb5c2","name":"istemp ","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"istemp ","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":520,"wires":[["3b1e2737.339e1"]]},{"id":"14d1c0a3.d1a227","type":"switch","z":"2999551d.7fb5c2","name":"isvolt ","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"isvolt ","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":580,"wires":[["1ab1d6ce.8c13d9"]]},{"id":"69a1088e.b32bf8","type":"switch","z":"2999551d.7fb5c2","name":"isseen ","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"isseen ","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":640,"wires":[["46dc1d0d.19c0a4"]]},{"id":"2229fbd.cac8d84","type":"mqtt-broker","z":"","name":"Home Assistant","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Brewpiless has MQTT communication, you can use this option to send data e receive commands directly from Home Assistant.
not on Sonoff Basic which doesn't support the new ui :(
Hmm - seems the space between topic and message is a deal breaker for HA. Will look at it later.
Maintaining multiple versions of UIs is PITA. I am going to ditch support of Sonoff in the coming versions.
It's not difficult to support MQTT if flash space isn't a issue, though.
I tried a version with MQTT for SONOFF. You might try if you want. https://github.com/vitotai/BrewPiLess/tree/Sonoff.mqtt