how to format string

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
krissam44
Posts: 3
Joined: Wednesday 16 August 2017 15:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

how to format string

Post by krissam44 »

Hello,

Here is a small script to write the temperature in a virtual text device

Code: Select all

return {
	on = {
		devices = {
			'Météo St-Jean de Braye'
		}
	},
	execute = function(domoticz, device)
	    local afficheur = domoticz.devices('T° St-Jean de Braye')           -- Nom de l'afficheur à mettre à jour
		afficheur.updateTemperature(tostring(device.temperature))
	end
}
I whould like to show only one figure after the decimal dot.
How to make this ?

Thanks
Attachments
temperature.png
temperature.png (10.63 KiB) Viewed 399 times
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: how to format string

Post by emme »

afficheur.updateTemperature(tostring(domoticz.round(device.temperature,1)))
The most dangerous phrase in any language is:
"We always done this way"
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest