Multiple data in one sensor

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
HvdW
Posts: 617
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Multiple data in one sensor

Post by HvdW »

There are lots of options to show multiple data in a condensed way.
Afaik there's dashticz, aurora, custom dashboard and probably others.
For those who like to stick with the default dashboard I'd like to explain with an example how one can display several data into one sensor using the Virtual Text Sensor.
We're using the Buienradar plugin data.
When you have installed buienradar you can see rain and upcoming rain information like this.
buienradar-1.jpg
buienradar-1.jpg (93.02 KiB) Viewed 1829 times
One can display the same information into a dummy text sensor like this.
buienradar-2.jpg
buienradar-2.jpg (26.5 KiB) Viewed 1829 times
The code is here. (just an example)

Code: Select all

-- Buienradar in text example

return {
	on = {
		timer = {'every 1 minutes'},
		},
	    logging = {
        level = domoticz.LOG_DEBUG,
        -- change LOG_DEBUG to LOG_ERROR to stop logging in the log
        marker = 'Buienradar in a textfile',
        },


	execute = function(domoticz, triggeredItem)
      
        -- domoticz.devices('Next Rainshower Leadtime').dump()
        -- domoticz.devices('Next Rainshower Duration').dump()
        -- domoticz.devices('Next Rainshower Avg Rainrate').dump()
        -- domoticz.devices('Next Rainshower Max Rainrate').dump()
        -- domoticz.devices('Rain Intensity').dump()
        -- domoticz.devices('Rainfall next Hour').dump()
        -- domoticz.devices('Rain').dump()
        
        --  ,  , and  
        -- math.floor(domoticz.devices('Tado Kamer Temp').temperature*10)/10 
        domoticz.devices('Buienradar text').updateText('Rain              ' .. math.floor(domoticz.devices('Rain').rain*10)/10 .. ' mm/h'..
            '\n Rain intensity           ' .. domoticz.devices('Rain Intensity').nValue .. ' %'..
            '\n Rainfall next Hour        ' .. domoticz.devices('Rainfall next Hour').nValue .. ' mm/h'..
            '\n \n \n    Next Rainshower Leadtime      ' .. math.floor(domoticz.devices('Next Rainshower Leadtime').sensorValue) .. ' min'..
            '\n    Next Rainshower Duration       ' .. math.floor(domoticz.devices('Next Rainshower Duration').sensorValue) .. ' min'..
            '\n    Next Rainshower Avg Rainrate   ' .. domoticz.devices('Next Rainshower Avg Rainrate').sensorValue .. ' mm/h'..
            '\n    Next Rainshower Max Rainrate   ' .. domoticz.devices('Next Rainshower Max Rainrate').sensorValue .. ' mm/h'..            '\n  ')
end
}
It takes a bit of time to arrage text and data on every line, but once it's done it doesn't need any maintenance.
In the code you see some lines with the dump() statement.
It is used to read the json output to be able to determin what data you need to pick to be displayed.
Bugs bug me.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest