Re: Dashticz V3.4.2 beta
Posted: Friday 03 April 2020 18:41
I have responded on the 'corona block' thread.
https://www.domoticz.com/forum/viewtopi ... 21#p242221
https://www.domoticz.com/forum/viewtopi ... 21#p242221
Did you define the subblocks in CONFIG.js?geertvercamer wrote: ↑Friday 03 April 2020 18:13 you're welcome.
Glad to learn something new.
new beta: the title of those blocks is gone
Code: Select all
config['units'] = {
names: {
kwh: 'kWh',
watt: 'W',
gas: 'm3',
water: 'l',
time: ''
},
decimals: {
kwh: 1,
watt: 0,
gas: 1,
water: 0,
time: 0
}
Code: Select all
function getStatus_142_1(idx,value,device){ //P1-smart meter: electricity usage
if(parseFloat(device['UsageDeliv'])>0){
$('div.block_142_1').addClass('background_green');
}
else {
$('div.block_142_1').removeClass('background_green');
}
}
Look at this Jake. There were a few changes: https://dashticz.readthedocs.io/en/bloc ... -idx-blockjake wrote: 2:To show from a distance when electricity usage is negative (more solar power than consumption) I made the background of the block green in custom.js. This doesn't work anymore, but it shows a '-' minus sign when there is a negative usage. What has changed?
Custom.js:Code: Select all
function getStatus_142_1(idx,value,device){ //P1-smart meter: electricity usage if(parseFloat(device['UsageDeliv'])>0){ $('div.block_142_1').addClass('background_green'); } else { $('div.block_142_1').removeClass('background_green'); } }
I'll look into the units, but it will take some time to fix.jake wrote: ↑Sunday 05 April 2020 20:04 As of 3.4.2 the configuration of 'units' doesn't work anymore. I don't find it back (anymore) either in the documentation.
Somewher in 2018 this feature was introducedHowever, in 3.4.2 I have 2 different results in 2 blocks:Code: Select all
config['units'] = { names: { kwh: 'kWh', watt: 'W', gas: 'm3', water: 'l', time: '' }, decimals: { kwh: 1, watt: 0, gas: 1, water: 0, time: 0 }
1:
blocks['142_1'] = {}
blocks['142_1']['width'] = 4;
blocks['142_1']['title'] = 'Usage' //power in Watt 'Smart Meter P1'
blocks['142_1']['unit'] = 'Watt;W';
It now shows as 100 W Watt;W (when I remove the last line about 'units', it shows as 100 Watt (instead of 'W'))
2:
blocks['240_1'] = {}
blocks['240_1']['width'] = 4;
blocks['240_1']['title'] = 'Harvested'; //power in Watt 'Solar Total Power'
blocks['240_1']['icon'] = 'fas fa-sun';
It shows as 100W (this is as it is wanted)
So, my 142 P1 meter doesn't seem to be recognized equal as the virtual device 240
1:How can I get both devices recognized the same, both showing the unit 'W'?
2:To show from a distance when electricity usage is negative (more solar power than consumption) I made the background of the block green in custom.js. This doesn't work anymore, but it shows a '-' minus sign when there is a negative usage. What has changed?
Custom.js:Code: Select all
function getStatus_142_1(idx,value,device){ //P1-smart meter: electricity usage if(parseFloat(device['UsageDeliv'])>0){ $('div.block_142_1').addClass('background_green'); } else { $('div.block_142_1').removeClass('background_green'); } }
Code: Select all
function getStatus_142_1(block) {
if(parseInt(block.device.UsageDeliv)>0 ) {
block.addClass= 'background_green'
}
else
block.addClass=''
}
You mean implementing the 'units' again, or straighting out the issue that one blocks says 'W' and the next 'Watt'?Lokonli wrote:I'll look into the units, but it will take some time to fix.jake wrote: ↑Sunday 05 April 2020 20:04 As of 3.4.2 the configuration of 'units' doesn't work anymore. I don't find it back (anymore) either in the documentation.
Somewher in 2018 this feature was introducedHowever, in 3.4.2 I have 2 different results in 2 blocks:Code: Select all
config['units'] = { names: { kwh: 'kWh', watt: 'W', gas: 'm3', water: 'l', time: '' }, decimals: { kwh: 1, watt: 0, gas: 1, water: 0, time: 0 }
1:
blocks['142_1'] = {}
blocks['142_1']['width'] = 4;
blocks['142_1']['title'] = 'Usage' //power in Watt 'Smart Meter P1'
blocks['142_1']['unit'] = 'Watt;W';
It now shows as 100 W Watt;W (when I remove the last line about 'units', it shows as 100 Watt (instead of 'W'))
2:
blocks['240_1'] = {}
blocks['240_1']['width'] = 4;
blocks['240_1']['title'] = 'Harvested'; //power in Watt 'Solar Total Power'
blocks['240_1']['icon'] = 'fas fa-sun';
It shows as 100W (this is as it is wanted)
So, my 142 P1 meter doesn't seem to be recognized equal as the virtual device 240
1:How can I get both devices recognized the same, both showing the unit 'W'?
Yes, this worked nice. I tried to build on to this example to upgrade my 2nd background thing as well. This one is slightly more complex, because I update the background color of block 321_1, based on status of block 79 (this is to color the gasmeter value red when the OTGWdevice 'central heater' is 'on'), but it doesn't do anything, although it used to do before:For the P1 meter: There was a request to present the value as a negative number in case of energy delivery, which I have implemented.
For the background color, add something like this in custom.js (the interface of the function slightly changed)Code: Select all
function getStatus_142_1(block) { if(parseInt(block.device.UsageDeliv)>0 ) { block.addClass= 'background_green' } else block.addClass='' }
Code: Select all
function getStatus_79(block) {
if(block.device.Status == 'Off' ) { //switch: Central Heating ON
'block_321_1'.addClass= 'background_red';
}
else
'block_321_1'.addClass='';
}
Code: Select all
function getStatus_79(idx,value,device){ //switch: Central Heating ON
if(device['Status']=='On'){
$('div.block_321_1').addClass('background_red'); //gas usage: Central Heating
}
else {
$('div.block_321_1').removeClass('background_red');
}
}
Code: Select all
function getStatus_79(block) {
if(block.device.Status == 'Off' ) { //switch: Central Heating ON
Dashticz.setBlock('321_1', {
addClass: 'background_red'
});
}
else
Dashticz.setBlock('321_1', {
addClass: ''
});
}
Correct, correct:Lokonli wrote:Because of the inline block definitions and the possibility to add domoticz IDs with different settings more than once I had to refactor the code significantly.
But the good news: I've added a function call to set the block parameters of a different block as well.
See https://dashticz.readthedocs.io/en/beta ... ther-block for an example.
In your case:I think you must have explicitly added '321_1' to a column. I'm not sure whether it works if you've added '321'Code: Select all
function getStatus_79(block) { if(block.device.Status == 'Off' ) { //switch: Central Heating ON Dashticz.setBlock('321_1', { addClass: 'background_red' }); } else Dashticz.setBlock('321_1', { addClass: '' }); }
Let me know
Further, you might have to replace Off with On in the above function.
Code: Select all
function getStatus_84(idx,value,device){
if(device['Status']=='Open'){
$('div.block_84').addClass('warning');
blocks['84']['icon'] = 'fas fa-door-open';
}
else {
$('div.block_84').removeClass('warning');
blocks['84']['icon'] = 'fas fa-door-closed';
}
}
Code: Select all
function getStatus_413(idx,value,device){
if(parseFloat(device['Usage'])>0){
blocks['413_1']['icon'] = 'fas fa-sun slow-spin'; //if you use "fa-spin" instead of "slow-spin" then it is not necessary to add code to custom.css
blocks['413_2']['icon'] = 'fas fa-sun slow-spin'; //if you use "fa-spin" instead of "slow-spin" then it is not necessary to add code to custom.css
blocks['413_3']['icon'] = 'fas fa-sun slow-spin'; //if you use "fa-spin" instead of "slow-spin" then it is not necessary to add code to custom.css
}
else {
blocks['413_1']['icon'] = 'fas fa-sun';
blocks['413_2']['icon'] = 'fas fa-sun';
blocks['413_3']['icon'] = 'fas fa-sun';
}
}
function getStatus_76_1(idx,value,device){
if(parseFloat(device['Usage'])>0){
blocks['76_1']['icon'] = 'fas fa-bolt';
}
else {
blocks['76_1']['icon'] = 'fas fa-sun slow-spin'; //if you use "fa-spin" instead of "slow-spin" then it is not necessary to add code to custom.css
}
}