help with function getStatus_2103_1

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

help with function getStatus_2103_1

Post by pvklink »

Hi i have a device that show the usage of my wasmachine.
I use id '2103_1' in config.js to show this device

I have the following function to change the ico and the title text, but it does work (anymore)
Can somebody give some help, how to get this working again?
When the wasmachine is in rest, it uses "0.7 Watt" (part two of the IF)
When it is more then 2, it is on... (part 1 of the IF)

2103 is the domoticzID 2103_1 in dashticz

function getStatus_2103_1(block) {
var usage = block.device.value;
if (parseFloat(usage) > 2) {
block.icon = 'fas fa-thermometer-full'
block.title = 'Wasmachine Aan'
} else {
block.icon = 'fas fa-thermometer-half'
block.title = 'Wasmachine Uit'
}
}

setting config.js
blocks['2103_1']= {title: 'Was machine', icon: 'fas fa-thermometer-half', hide_data: true, width: 4, switch: true, last_update: false}


dashtix userinterface (part)
wasm.jpg
wasm.jpg (9.26 KiB) Viewed 155 times

Code: Select all

{
	"ActTime" : 1610906808,
	"AstrTwilightEnd" : "19:05",
	"AstrTwilightStart" : "06:41",
	"CivTwilightEnd" : "17:43",
	"CivTwilightStart" : "08:03",
	"DayLength" : "08:23",
	"NautTwilightEnd" : "18:25",
	"NautTwilightStart" : "07:21",
	"ServerTime" : "2021-01-17 19:06:48",
	"SunAtSouth" : "12:53",
	"Sunrise" : "08:42",
	"Sunset" : "17:04",
	"app_version" : "2020.2 (build 12847)",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"CounterToday" : "2.150 kWh",
			"CustomImage" : 0,
			"Data" : "179.430 kWh",
			"Description" : "",
			"EnergyMeterMode" : "0",
			"Favorite" : 0,
			"HardwareDisabled" : false,
			"HardwareID" : 31,
			"HardwareName" : "zwavepluspvk",
			"HardwareType" : "OpenZWave USB",
			"HardwareTypeVal" : 21,
			"HaveTimeout" : false,
			"ID" : "00000E01",
			"LastUpdate" : "2021-01-17 19:06:30",
			"Name" : "wasmachine_kwh_oud3",
			"Notifications" : "false",
			"PlanID" : "0",
			"PlanIDs" : 
			[
				0
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "kWh",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "General",
			"TypeImg" : "current",
			"Unit" : 1,
			"Usage" : "0.7 Watt",
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "2103"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Lokonli
Posts: 2291
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: help with function getStatus_2103_1

Post by Lokonli »

pvklink wrote: Sunday 17 January 2021 15:48 Hi i have a device that show the usage of my wasmachine.
I use id '2103_1' in config.js to show this device

I have the following function to change the ico and the title text, but it does work (anymore)
Can somebody give some help, how to get this working again?
When the wasmachine is in rest, it uses "0.7 Watt" (part two of the IF)
When it is more then 2, it is on... (part 1 of the IF)

2103 is the domoticzID 2103_1 in dashticz

function getStatus_2103_1(block) {
var usage = block.device.value;
if (parseFloat(usage) > 2) {
block.icon = 'fas fa-thermometer-full'
block.title = 'Wasmachine Aan'
} else {
block.icon = 'fas fa-thermometer-half'
block.title = 'Wasmachine Uit'
}
}

setting config.js
blocks['2103_1']= {title: 'Was machine', icon: 'fas fa-thermometer-half', hide_data: true, width: 4, switch: true, last_update: false}


dashtix userinterface (part)
wasm.jpg

Code: Select all

{
	"ActTime" : 1610906808,
	"AstrTwilightEnd" : "19:05",
	"AstrTwilightStart" : "06:41",
	"CivTwilightEnd" : "17:43",
	"CivTwilightStart" : "08:03",
	"DayLength" : "08:23",
	"NautTwilightEnd" : "18:25",
	"NautTwilightStart" : "07:21",
	"ServerTime" : "2021-01-17 19:06:48",
	"SunAtSouth" : "12:53",
	"Sunrise" : "08:42",
	"Sunset" : "17:04",
	"app_version" : "2020.2 (build 12847)",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"CounterToday" : "2.150 kWh",
			"CustomImage" : 0,
			"Data" : "179.430 kWh",
			"Description" : "",
			"EnergyMeterMode" : "0",
			"Favorite" : 0,
			"HardwareDisabled" : false,
			"HardwareID" : 31,
			"HardwareName" : "zwavepluspvk",
			"HardwareType" : "OpenZWave USB",
			"HardwareTypeVal" : 21,
			"HaveTimeout" : false,
			"ID" : "00000E01",
			"LastUpdate" : "2021-01-17 19:06:30",
			"Name" : "wasmachine_kwh_oud3",
			"Notifications" : "false",
			"PlanID" : "0",
			"PlanIDs" : 
			[
				0
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "kWh",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "General",
			"TypeImg" : "current",
			"Unit" : 1,
			"Usage" : "0.7 Watt",
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "2103"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
The first line in the function is incorrect:

Code: Select all

var usage = block.device.value;
As you can see in the Domoticz device json dump, you see there is no key 'value' in the result part.
Probaby you want to use the field 'Usage'

so change the line to the following:

Code: Select all

var usage = block.device.Usage;
Javascript is case sensitive.
All Domoticz device fields, except idx, start with an uppercase character. So 'block.device.usage' will not work.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest