wcavanagh
(Will Cavanagh)
March 10, 2024, 8:38pm
1
I am very new to this, I have a Owl Electric monitor that send UDP data out, the integration that used to read this no longer works, so I need to setup my own in node red. I have a UDP listen working and into Debug I see the UDP data. How do I pull out certain values from this to put into a sensor. E.g. Battery Voltage, Phase 1 power, Phase 2 Power, etc.
<electricity id='44371914BDB1' ver='2.0'><timestamp>1710102893</timestamp><signal rssi='-73' lqi='89'/><battery level='100%'/><channels><chan id='0'><curr units='w'>243.00</curr><day units='wh'>6866.33</day></chan><chan id='1'><curr units='w'>0.00</curr><day units='wh'>0.00</day></chan><chan id='2'><curr units='w'>788.00</curr><day units='wh'>12200.66</day></chan><chan id='3'><curr units='w'>0.00</curr><day units='wh'>0.00</day></chan><chan id='4'><curr units='w'>0.00</curr><day units='wh'>0.00</day></chan><chan id='5'><curr units='w'>0.00</curr><day units='wh'>0.00</day></chan></channels><property><current><watts>243.00</watts><cost>5.29</cost></current><day><wh>6866.33</wh><cost>188.56</cost></day><tariff time='1710102893'><start>1710028800</start><curr_price>0.22</curr_price><block_limit>4294967295</block_limit><block_usage>5282</block_usage></tariff></property></electricity>
Kermit
March 11, 2024, 6:31am
2
Use an XML node to convert it to a JSON object. Then you can reference the values in a sensor node.
wcavanagh
(Will Cavanagh)
March 11, 2024, 7:08pm
3
Thank you, im very new to this, so how do i configure the node?
Kermit
March 11, 2024, 7:24pm
4
[{"id":"4616d54dab210904","type":"xml","z":"120358abd7c22d30","name":"","property":"payload","attr":"","chr":"","x":1006,"y":2704,"wires":[["a4f896ae8ea0e659"]]},{"id":"aeaeda44d759cc66","type":"inject","z":"120358abd7c22d30","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<electricity id='44371914BDB1' ver='2.0'><timestamp>1710102893</timestamp><signal rssi='-73' lqi='89'/><battery level='100%'/><channels><chan id='0'><curr units='w'>243.00</curr><day units='wh'>6866.33</day></chan><chan id='1'><curr units='w'>0.00</curr><day units='wh'>0.00</day></chan><chan id='2'><curr units='w'>788.00</curr><day units='wh'>12200.66</day></chan><chan id='3'><curr units='w'>0.00</curr><day units='wh'>0.00</day></chan><chan id='4'><curr units='w'>0.00</curr><day units='wh'>0.00</day></chan><chan id='5'><curr units='w'>0.00</curr><day units='wh'>0.00</day></chan></channels><property><current><watts>243.00</watts><cost>5.29</cost></current><day><wh>6866.33</wh><cost>188.56</cost></day><tariff time='1710102893'><start>1710028800</start><curr_price>0.22</curr_price><block_limit>4294967295</block_limit><block_usage>5282</block_usage></tariff></property></electricity>","payloadType":"str","x":850,"y":2704,"wires":[["4616d54dab210904"]]},{"id":"a4f896ae8ea0e659","type":"debug","z":"120358abd7c22d30","name":"debug 168","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1174,"y":2704,"wires":[]}]
An easy to get the path of the property is to use the debug panel and click “copy path” button when you hover over the property.
wcavanagh
(Will Cavanagh)
March 11, 2024, 7:43pm
5
Thank you, awesome so now I see the path to the object I want, how do I set this into a sensor to be visible in HA
So sorry is this is dumb
Kermit
March 11, 2024, 7:56pm
6
Do you want individual sensors for each property or one sensor with attributes?
wcavanagh
(Will Cavanagh)
March 11, 2024, 8:02pm
7
I need to make several induvial sensors please
Kermit
March 11, 2024, 8:10pm
8
and set the state to correct property
wcavanagh
(Will Cavanagh)
March 11, 2024, 8:17pm
9
You are amazing, it is working
wcavanagh
(Will Cavanagh)
March 11, 2024, 9:20pm
10
One last question, is there an easy way to then divide one of the sensor values by 1000? So I am getting 8284W and want to divide by 1000 to 8.28Kw
Kermit
March 11, 2024, 10:04pm
11
Set the state type to J: expression
, JSONata, and use something like
$round(payload.electricity.battery[0].$.level / 1000, 2)
wcavanagh
(Will Cavanagh)
March 12, 2024, 10:01am
12
I changed this line
payload.electricity.channels[0].chan[0].day[0]._
Thank you, so I set like this.
$round(payload.electricity.channels[0].chan[0].day[0]._ / 1000, 2)
But get this error.
The input message doesn’t have have a msg.payload.electricity.channels[0].chan[0].day[0]._ field
Mikefila
(Mike Fila)
March 12, 2024, 10:51am
13
When a number is in quotes "6866.33"
it is being sent as a string. Use $number()
to convert it.
Make sure the spacing stays the same as what I posted.
$round($number(payload.electricity.channels[0].chan[0].day[0]._) / 1000, 2)
wcavanagh
(Will Cavanagh)
March 12, 2024, 1:41pm
14
You are AMAZING
Thank you so much, that is working perfect
Life saver.