local scriptVar = 'currentHashrate'
return
{
on =
{
timer =
{
'every 1 minutes', -- change to required frequency
},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all ok
marker = 'miner',
},
execute = function(domoticz, item)
if item.isTimer then
domoticz.openURL(
{
url = 'https://api.ethermine.org/miner/mymineraddress/currentStats/',
callback = scriptVar,
})
end
if (item.isHTTPResponse and item.ok) then
domoticz.devices('Hashrate').updateCustomSensor(domoticz.utils.round(item.json.data.currentHashrate, 3))
end
end
}
Now works. Thank you very much. I have one more question, the return value is in this form 1.99167e+08. But when I set my virtual device to "text", and raplece "domoticz.devices('Hashrate').updateCustomSensor(domoticz.utils.round(item.json.data.currentHashrate, 3))" to "domoticz.devices('Hashrate').updateText(domoticz.utils.round(item.json.data.currentHashrate, 3))" the value is correct 199166666.6667. How can I covert floating value to an integer? Sorry but my domoticz skills are very limited.
bolek wrote: ↑Friday 26 March 2021 8:01
I have one more question. How can I covert floating value to an integer? Sorry but my domoticz skills are very limited.
the conversion to scientific notation is something that is done deeper in domoticz for counter- and custom sensor type of devices. This cannot be influenced by dzVents.
Conversion (which will obviously include rounding) to integer in dzVents (= Lua) can be done using the math.floor() function.