Prøv å importer denne i Node-RED og velg din egen broker:
[{"id":"ce403b1c.4525","type":"tab","label":"Read Victron BMV","disabled":false,"info":""},{"id":"a5f0ebb8.a8ffc8","type":"serial in","z":"ce403b1c.4525","name":"Victron","serial":"4c5b552e.7251c4","x":70,"y":20,"wires":[["da87e7f0.e6718"]]},{"id":"da87e7f0.e6718","type":"function","z":"ce403b1c.4525","name":"Convert_obj","func":"// 'msg' is the message object the Function node receives\nvar myVars = msg.payload.split(\"\\r\\n\");\nvar result = {};\nmyVars.forEach(function(v) {\n // The following split uses ' = ' - because your example output appears to\n // have spaces around the equals sign.\n var parts = v.split(\"\\t\");\n result[parts[0]] = parts[1];\n});\nmsg.payload = result;\n// The Function node returns the message to be sent to the next node(s) in the flow\nreturn msg;","outputs":1,"noerr":0,"x":210,"y":60,"wires":[["680afb51.ab5e1c"]]},{"id":"680afb51.ab5e1c","type":"split","z":"ce403b1c.4525","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":true,"addname":"topic","x":190,"y":120,"wires":[["3d345f2d.9c5ec8"]]},{"id":"3d345f2d.9c5ec8","type":"switch","z":"ce403b1c.4525","name":"Route","property":"parts.key","propertyType":"msg","rules":[{"t":"eq","v":"V","vt":"str"},{"t":"eq","v":"I","vt":"str"},{"t":"eq","v":"SOC","vt":"str"},{"t":"eq","v":"VS","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":190,"y":256,"wires":[["4d37d79.a5d7928"],["f6bacaa.6ad00b8"],["2fbb3a67.32bd4e"],["57ab5db5.514494"]]},{"id":"4d37d79.a5d7928","type":"change","z":"ce403b1c.4525","name":"V to num","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(msg.payload)/1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":176,"wires":[["64427d47.57b5d4"]]},{"id":"f6bacaa.6ad00b8","type":"change","z":"ce403b1c.4525","name":"I to num","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(msg.payload)/1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":256,"wires":[["c9b3ba75.0f5478"]]},{"id":"5357269c.900ea","type":"mqtt out","z":"ce403b1c.4525","name":"Volt","topic":"homeassistant/sensor/battV/state","qos":"","retain":"","broker":"","x":670,"y":220,"wires":[]},{"id":"2fbb3a67.32bd4e","type":"change","z":"ce403b1c.4525","name":"SoC to num","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(msg.payload)/10","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":356,"wires":[["94422a53.c8792"]]},{"id":"eb439af0.4a43e","type":"mqtt out","z":"ce403b1c.4525","name":"Current","topic":"homeassistant/sensor/battA/state","qos":"","retain":"","broker":"","x":680,"y":300,"wires":[]},{"id":"7171e67b.139218","type":"mqtt out","z":"ce403b1c.4525","name":"SOC","topic":"homeassistant/sensor/battSOC/state","qos":"","retain":"","broker":"","x":670,"y":400,"wires":[]},{"id":"c9b3ba75.0f5478","type":"smooth","z":"ce403b1c.4525","name":"Two dec","property":"payload","action":"mean","count":"5","round":"2","mult":"multi","x":520,"y":300,"wires":[["eb439af0.4a43e"]]},{"id":"94422a53.c8792","type":"smooth","z":"ce403b1c.4525","name":"No dec","property":"payload","action":"mean","count":"5","round":"0","mult":"multi","x":520,"y":400,"wires":[["7171e67b.139218"]]},{"id":"57ab5db5.514494","type":"change","z":"ce403b1c.4525","name":"V to num","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(msg.payload)/1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":440,"wires":[["59f1d6ea.0b1c78"]]},{"id":"9d0264be.92d988","type":"mqtt out","z":"ce403b1c.4525","name":"Start Volt","topic":"homeassistant/sensor/battVS/state","qos":"","retain":"","broker":"","x":680,"y":480,"wires":[]},{"id":"64427d47.57b5d4","type":"smooth","z":"ce403b1c.4525","name":"Two dec","property":"payload","action":"mean","count":"5","round":"2","mult":"multi","x":520,"y":220,"wires":[["5357269c.900ea"]]},{"id":"59f1d6ea.0b1c78","type":"smooth","z":"ce403b1c.4525","name":"Two dec","property":"payload","action":"mean","count":"5","round":"2","mult":"multi","x":520,"y":480,"wires":[["9d0264be.92d988"]]},{"id":"257e6718.bc5b48","type":"mqtt out","z":"ce403b1c.4525","name":"ampconfig","topic":"homeassistant/sensor/battA/config","qos":"","retain":"true","broker":"","x":310,"y":580,"wires":[]},{"id":"7bfa37cf.915f48","type":"mqtt out","z":"ce403b1c.4525","name":"socconfig","topic":"homeassistant/sensor/battSOC/config","qos":"","retain":"true","broker":"","x":300,"y":620,"wires":[]},{"id":"d31575ac.44fab8","type":"mqtt out","z":"ce403b1c.4525","name":"voltconfig","topic":"homeassistant/sensor/battV/config","qos":"","retain":"true","broker":"","x":300,"y":540,"wires":[]},{"id":"13fd40a8.c915ef","type":"mqtt out","z":"ce403b1c.4525","name":"voltsconfig","topic":"homeassistant/sensor/battVS/config","qos":"","retain":"true","broker":"","x":310,"y":660,"wires":[]},{"id":"bcbc5d8b.2dba9","type":"inject","z":"ce403b1c.4525","name":"ajsonn","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"{\"name\":\"Øyeblikksforbruk\",\"unique_id\":\"2222\",\"device\":{\"identifiers\":\"boat1\"},\"icon\":\"mdi:resistor\",\"unit_of_measurement\":\"A\",\"state_topic\":\"homeassistant/sensor/battA/state\"}","payloadType":"json","x":124,"y":588,"wires":[["257e6718.bc5b48"]]},{"id":"985be2fd.87dec","type":"inject","z":"ce403b1c.4525","name":"socjson","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"{\"name\":\"Batterinivå\",\"unique_id\":\"3333\",\"device\":{\"identifiers\":\"boat1\"},\"device_class\":\"battery\",\"unit_of_measurement\":\"%\",\"state_topic\":\"homeassistant/sensor/battSOC/state\"}","payloadType":"json","x":124,"y":628,"wires":[["7bfa37cf.915f48"]]},{"id":"ccd43fd0.9a51a","type":"inject","z":"ce403b1c.4525","name":"voltjson","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"{\"name\":\"Forbruksbatteri\",\"unique_id\":\"111\",\"device\":{\"identifiers\":\"boat1\",\"name\":\"Båt 1\"},\"icon\":\"mdi:current-dc\",\"unit_of_measurement\":\"V\",\"state_topic\":\"homeassistant/sensor/battV/state\"}","payloadType":"json","x":124,"y":548,"wires":[["d31575ac.44fab8"]]},{"id":"e65c6965.c0e008","type":"inject","z":"ce403b1c.4525","name":"vsjson","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"{\"name\":\"Startbatteri\",\"unique_id\":\"4444\",\"device\":{\"identifiers\":\"boat1\"},\"icon\":\"mdi:current-dc\",\"unit_of_measurement\":\"V\",\"state_topic\":\"homeassistant/sensor/battVS/state\"}","payloadType":"json","x":124,"y":668,"wires":[["13fd40a8.c915ef"]]},{"id":"31147038.07538","type":"comment","z":"ce403b1c.4525","name":"Trykk på disse en gang","info":"","x":150,"y":492,"wires":[]},{"id":"4c5b552e.7251c4","type":"serial-port","serialport":"/dev/ttyUSB0","serialbaud":"19200","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false,"responsetimeout":"600"}]
Da skal du få noe sånt:
Denne må du sikkert ha i configuration.yaml
mqtt:
discovery: true
discovery_prefix: homeassistant
----------------------------------------------------
En liten guide for å sende verdier fra Node-RED til Home Assistant:
(Det finnes også andre måter å gjøre det på)
Kopier denne "test" flowen inni Node-RED:
[{"id":"f1950d3b.64d48","type":"debug","z":"6e6fc6e9.cf32f8","name":"debug","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":631,"y":250,"wires":[]},{"id":"fb8f84c8.ee7228","type":"mqtt out","z":"6e6fc6e9.cf32f8","name":"bytt ut\"test01\"","topic":"homeassistant/sensor/test01/state","qos":"","retain":"","broker":"aeecd9ba.13dc78","x":621,"y":307,"wires":[]},{"id":"2d17f84e.edd118","type":"inject","z":"6e6fc6e9.cf32f8","name":"bytt ut test01 i \"state_topic\" + TestSensor01 i \"name\".","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"{\"name\":\"TestSensor01\",\"state_topic\":\"homeassistant/sensor/test01/state\",\"icon\":\"mdi:test-tube\"}","payloadType":"json","x":381,"y":448,"wires":[["afaaecf2.b64b7"]]},{"id":"afaaecf2.b64b7","type":"mqtt out","z":"6e6fc6e9.cf32f8","name":"bytt ut \"test01\"","topic":"homeassistant/sensor/test01/config","qos":"","retain":"true","broker":"aeecd9ba.13dc78","x":719,"y":448,"wires":[]},{"id":"2c8aa1df.987a0e","type":"random","z":"6e6fc6e9.cf32f8","name":"En verdi mellom 1 og 100","low":"1","high":"100","inte":"true","property":"payload","x":341,"y":307,"wires":[["f1950d3b.64d48","fb8f84c8.ee7228"]]},{"id":"e7e39d2f.0b8f7","type":"inject","z":"6e6fc6e9.cf32f8","name":"Send verdi hvert 5sek","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"500","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":344.5,"y":249,"wires":[["2c8aa1df.987a0e"]]},{"id":"e1d70e55.9ad74","type":"comment","z":"6e6fc6e9.cf32f8","name":"Kjør denne en gang for å sett inn sensoren i HA","info":"Bytt ut test01 med det du vil","x":402.5,"y":403,"wires":[]},{"id":"aeecd9ba.13dc78","type":"mqtt-broker","name":"Broker Hass.io","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"homeassistant/node-red/status","birthQos":"1","birthRetain":"true","birthPayload":"Online","closeTopic":"homeassistant/node-red/status","closeQos":"1","closeRetain":"true","closePayload":"","willTopic":"homeassistant/node-red/status","willQos":"1","willRetain":"true","willPayload":"Disconnect"}]
Da vil du få dette:
Dobbel klikk på mqtt noden:
Velg din Broker eller lag ny til din Broker.
Sjekk at ip og port til broker er riktig, jeg bruker Mosquitto broker i Add-on, da blir det localhost og 1883:
Sjekk at brukernavn og passord er riktige:
Kjør Deploy, så skal sensoren komme inn i Home Assistant.
Her står det mye god info: https://www.home-assistant.io/docs/mqtt/discovery/