Combine 2 different idx devices in 1 block

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
cornesch
Posts: 19
Joined: Sunday 10 November 2019 19:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Combine 2 different idx devices in 1 block

Post by cornesch »

Hello Everyone,

Is it possible to display 2 separate devices in 1 block in Dashticz?

I mean a humidity meter and air quality meter.
I would like to see this: (55% / 471ppm)
>>Raspberry Pi 4<<>>Raspberry Pi 3 + 7-inch Touchscreen<<>>Ikea Tradfri<<>>Nefit Easy<<>>ESP-Easy<<>>Netatmo<<>>Sonos<<
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Combine 2 different idx devices in 1 block

Post by Lokonli »

You can create a dummy text device in Domoticz, and with some Domoticz scripting fill it with the data from the humidity and air quality sensors.

or, do it in Dashticz, but that will require some coding as well:

1) Add the device that changes most often to Dashticz
If this is the humidity meter, then I expect it's a TempHum sensor. You probably need subdevice 2:

So assume your temp device is 100, air quality 200.

In CONFIG.js:

Code: Select all

columns[1] = {
   blocks: [ '100_2']
}
2) Add the following to custom.js:

Code: Select all

function getStatus_100_2(block) {
	var humDevice = block.device;
	var airDevice = Domoticz.getAllDevices()[200];
	console.log(humDevice);
	console.log(airDevice);
	block.value = humDevice.Humidity + ' / ' + airDevice.Data
}
The two console statements will help in the debugging. Open DevTools (F12), then on the console tab you should see the device info printed, when the device gets updated. If it's working you can remove the console statements of course.
cornesch
Posts: 19
Joined: Sunday 10 November 2019 19:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Combine 2 different idx devices in 1 block

Post by cornesch »

Thanks for the tips @lokonli !

I finally solved it like below to get it working:

Code: Select all

function getStatus_235(block) {
	var airDevice = Domoticz.getAllDevices()[235];
	var humDevice = Domoticz.getAllDevices()[234];
	block.value = humDevice.Humidity + ' % ';
        block.title = airDevice.Data 
}
>>Raspberry Pi 4<<>>Raspberry Pi 3 + 7-inch Touchscreen<<>>Ikea Tradfri<<>>Nefit Easy<<>>ESP-Easy<<>>Netatmo<<>>Sonos<<
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest