Vous avez créé un script LUA dont vous êtes fier, un .sh génial, un programme Python hors du commun, un Tuto, c'est ici que vous pouvez les partager.
calouis
Messages : 109 Inscription : 08 nov. 2015, 10:34
Localisation : 62
Message
par calouis » 09 août 2019, 18:47
@Papoo
Je suis revenu sur une sauvegarde :
Version: 4.10547
dzVents Version: 2.4.15
J'ai recréé bouton selecteur id 194...qui fonctionne manuellement ou en json !
Même résultat : pas d'actualisation automatique...
Code : Tout sélectionner
2019-08-09 18:42:25.914 Status: dzVents: Info: moonSelectorIcons v 1.0: ------ Start internal script: moonSelectorIcons: Device: "Lune (Virtuel)", Index: 194
2019-08-09 18:42:25.914 Status: dzVents: Debug: moonSelectorIcons v 1.0: lastLevel20
2019-08-09 18:42:25.914 Status: dzVents: Debug: moonSelectorIcons v 1.0: level10
2019-08-09 18:42:25.914 Status: dzVents: Debug: moonSelectorIcons v 1.0: http://127.0.0.1:8280/json.htm?type=setused&used=true&name=Lune&description=&idx=194&switchtype=18&customimage=102
2019-08-09 18:42:25.914 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: url = http://127.0.0.1:8280/json.htm?type=setused&used=true&name=Lune&description=&idx=194&switchtype=18&customimage=102
2019-08-09 18:42:25.915 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: method = GET
2019-08-09 18:42:25.915 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: post data = nil
2019-08-09 18:42:25.915 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: headers = nil
2019-08-09 18:42:25.915 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: callback = nil
2019-08-09 18:42:25.915 Status: dzVents: Info: moonSelectorIcons v 1.0: ------ Finished moonSelectorIcons
2019-08-09 18:43:00.341 Status: dzVents: Info: moon phase v1.01: ------ Start internal script: moonPhase:, trigger: every minute
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: 7.7088949999672
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: 7.7088949999672
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: moon text : Premier quartier
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: level : 30
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: switch selector name : Lune
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: switch selector id : 194
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: last level switch selector : 10
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: Constructed timed-command: Set Level 30
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: update selector device
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: level switch selector : 10
2019-08-09 18:43:00.344 Status: dzVents: Debug: moon phase v1.01: level name switch selector : Nouvelle lune
2019-08-09 18:43:00.345 Status: dzVents: Info: moon phase v1.01: ------ Finished moonPhase
_ Raspberry Pi3 Stretch + Domoticz V4.11214
_ dzVents Version: 2.4.28
_ Python 3.5.3
_ usbZwave
_ RFX433XL USB Version: Pro XL1/1035
_ GW Xiaomi
_ station meteo Oregon & Netatmo
_ LMS
_ Yeelight
_ Tradfri
_ Zigate plugin 4.11.012 + Version : 031d
papoo
Messages : 2029 Inscription : 10 janv. 2016, 11:29
Localisation : Limoges (87)
Contact :
Message
par papoo » 10 août 2019, 10:48
je ne sais pas comment t'aider
tous les tests que j'ai pu faire sur différentes machines et differents switchs selector fonctionnent
je vais regarder si une mise à jour du selector via json est simple à faire
calouis
Messages : 109 Inscription : 08 nov. 2015, 10:34
Localisation : 62
Message
par calouis » 10 août 2019, 12:18
En tout cas, merci pour ton implication...Tes scripts sont très pédagogiques pour un amateur que suis !
_ Raspberry Pi3 Stretch + Domoticz V4.11214
_ dzVents Version: 2.4.28
_ Python 3.5.3
_ usbZwave
_ RFX433XL USB Version: Pro XL1/1035
_ GW Xiaomi
_ station meteo Oregon & Netatmo
_ LMS
_ Yeelight
_ Tradfri
_ Zigate plugin 4.11.012 + Version : 031d
Gaz
Messages : 224 Inscription : 17 oct. 2015, 10:30
Message
par Gaz » 10 août 2019, 17:11
Merci Papoo.
Aucun problème de fonctionnement chez moi.
papoo
Messages : 2029 Inscription : 10 janv. 2016, 11:29
Localisation : Limoges (87)
Contact :
Message
par papoo » 10 août 2019, 21:12
@gaz : merci de ton retour, je me demandais si le script fonctionnait seulement chez moi.
@calouis : une version spéciale pour toi et ton impossibilité de mettre à jour un selecteur directement par dzvents
(testé chez moi et fonctionnel)
Code : Tout sélectionner
--[[
author/auteur = papoo
update/mise à jour = 08/08/2019
creation = 04/08/2019
source https://github.com/JamesSherburne/MoonPhasesLua/blob/master/main.lua
https://pon.fr/dzvents-phases-lunaires-sans-api
https://easydomoticz.com/forum/viewtopic.php?f=17&t=8789
--]]
local scriptName = 'moon phase'
local scriptVersion = '1.01 for calouis'
local MoonPhaseSelector = 1301
--local Waning_Crescent = "Waning Crescent" -- level 80 MoonPhase Selector switch
local Waning_Crescent = "Dernier croissant" -- level 80 MoonPhase Selector switch
--local Last_Quarter = "Last Quarter" -- level 70 MoonPhase Selector switch
local Last_Quarter = "Dernier quartier" -- level 70 MoonPhase Selector switch
--local Waning gibbous = "Waning gibbous" -- level 60 MoonPhase Selector switch
local Waning gibbous = "gibbeuse décroissante" -- level 60 MoonPhase Selector switch
--local Full_Moon = "Full Moon" -- level 50 MoonPhase Selector switch
local Full_Moon = "Pleine une" -- level 50 MoonPhase Selector switch
--local Waxing_gibbous = "Waxing gibbous" -- level 40 MoonPhase Selector switch
local Waxing_gibbous = "Gibbeuse croissante" -- level 40 MoonPhase Selector switch
--local First_Moon = "First Moon" -- level 30 MoonPhase Selector switch
local First_Moon = "Premier quartier" -- level 30 MoonPhase Selector switch
--local Waxing_crescent = "Waxing crescent" -- level 20 MoonPhase Selector switch
local Waxing_crescent = "Premier croissant" -- level 20 MoonPhase Selector switch
--local New_Moon = "New Moon" -- level 10 MoonPhase Selector switch
local New_Moon = "Nouvelle lune" -- level 10 MoonPhase Selector switch
return {
active = true,
on = { timer = {'every minute'}},
logging = { level = domoticz.LOG_DEBUG,
-- level = domoticz.LOG_INFO, -- Seulement un niveau peut être actif; commenter les autres
-- level = domoticz.LOG_ERROR, -- Only one level can be active; comment others
-- level = domoticz.LOG_MODULE_EXEC_INFO,
marker = scriptName..' v'..scriptVersion },
execute = function(domoticz)
local function logWrite(str,level) -- Support function for shorthand debug log statements
domoticz.log(tostring(str),level or domoticz.LOG_DEBUG)
end
local function julianDate(d, m, y)
local mm, yy, k1, k2, k3, j
yy = y - math.floor((12 - m) / 10)
mm = m + 9
if (mm >= 12) then
mm = mm - 12
end
k1 = math.floor(365.25 * (yy + 4712))
k2 = math.floor(30.6001 * mm + 0.5)
k3 = math.floor(math.floor((yy / 100) + 49) * 0.75) - 38
j = k1 + k2 + d + 59
if (j > 2299160) then
j = j - k3
end
return j
end
local function moonAge(d, m, y)
local j, ip, ag
j = julianDate(d, m, y)
ip = (j + 4.867) / 29.53059
ip = ip - math.floor(ip)
if (ip < 0.5) then
ag = ip * 29.53059 + 29.53059 / 2
else
ag = ip * 29.53059 - 29.53059 / 2
end
logWrite(ag)
return ag
end
local day = os.date("%d")
local month = os.date("%m")
local year = os.date("%Y")
local theMoon = moonAge(day,month,year)
logWrite(theMoon)
if theMoon >= 29 then
moonText = New_Moon
level = 10
elseif theMoon < 29 and theMoon > 23 then
moonText = Waning_Crescent
level = 80
elseif theMoon < 23 and theMoon > 22 then
moonText = Last_Quarter
level = 70
elseif theMoon < 22 and theMoon > 15 then
moonText = Waning_gibbous
level = 60
elseif theMoon < 15 and theMoon > 13 then
moonText = Full_Moon
level = 50
elseif theMoon < 13 and theMoon > 8 then
moonText = Waxing_gibbous
level = 40
elseif theMoon < 8 and theMoon > 6 then
moonText = First_Moon
level = 30
elseif theMoon < 6 and theMoon > 1 then
moonText = Waxing_crescent
level = 20
else
moonText = New_Moon
level = 10
end
logWrite("moon text : "..moonText)
logWrite("level : "..level)
if (MoonPhaseSelector) then
logWrite("switch selector name : "..domoticz.devices(MoonPhaseSelector).name)
logWrite("switch selector id : "..domoticz.devices(MoonPhaseSelector).id)
logWrite("last level switch selector : "..domoticz.devices(MoonPhaseSelector).lastLevel)
if (domoticz.devices(MoonPhaseSelector).lastLevel ~= level) then
-- domoticz.devices(MoonPhaseSelector).switchSelector(level)
url = domoticz.settings['Domoticz url'] .. '/json.htm?type=command¶m=switchlight&idx='.. domoticz.devices(MoonPhaseSelector).id ..'&switchcmd=Set%20Level&level='.. level
domoticz.openURL(url)
logWrite("update selector device")
else
logWrite("no update needed")
end
logWrite("level switch selector : "..domoticz.devices(MoonPhaseSelector).level)
logWrite("level name switch selector : "..domoticz.devices(MoonPhaseSelector).levelName)
end
end -- execute function
}
calouis
Messages : 109 Inscription : 08 nov. 2015, 10:34
Localisation : 62
Message
par calouis » 11 août 2019, 18:47
@Papoo
1er essai transformé
un grand merci Papoo
Code : Tout sélectionner
2019-08-11 18:44:02.094 Status: dzVents: Write file: /home/pi/domoticz/scripts/dzVents/generated_scripts/moonSelectorIcons.lua
2019-08-11 18:44:02.094 Status: dzVents: Write file: /home/pi/domoticz/scripts/dzVents/generated_scripts/moonPhase.lua
2019-08-11 18:45:00.736 Status: dzVents: Info: moon phase v1.01 for calouis: ------ Start internal script: moonPhase:, trigger: every minute
2019-08-11 18:45:00.737 Status: dzVents: Debug: moon phase v1.01 for calouis: 9.7088949999718
2019-08-11 18:45:00.737 Status: dzVents: Debug: moon phase v1.01 for calouis: 9.7088949999718
2019-08-11 18:45:00.738 Status: dzVents: Debug: moon phase v1.01 for calouis: moon text : Gibbeuse croissante
2019-08-11 18:45:00.738 Status: dzVents: Debug: moon phase v1.01 for calouis: level : 40
2019-08-11 18:45:00.738 Status: dzVents: Debug: moon phase v1.01 for calouis: switch selector name : Lune
2019-08-11 18:45:00.738 Status: dzVents: Debug: moon phase v1.01 for calouis: switch selector id : 194
2019-08-11 18:45:00.738 Status: dzVents: Debug: moon phase v1.01 for calouis: last level switch selector : 10
2019-08-11 18:45:00.738 Status: dzVents: Debug: moon phase v1.01 for calouis: OpenURL: url = http://127.0.0.1:8280/json.htm?type=command¶m=switchlight&idx=194&switchcmd=Set%20Level&level=40
2019-08-11 18:45:00.738 Status: dzVents: Debug: moon phase v1.01 for calouis: OpenURL: method = GET
2019-08-11 18:45:00.738 Status: dzVents: Debug: moon phase v1.01 for calouis: OpenURL: post data = nil
2019-08-11 18:45:00.738 Status: dzVents: Debug: moon phase v1.01 for calouis: OpenURL: headers = nil
2019-08-11 18:45:00.738 Status: dzVents: Debug: moon phase v1.01 for calouis: OpenURL: callback = nil
2019-08-11 18:45:00.739 Status: dzVents: Debug: moon phase v1.01 for calouis: update selector device
2019-08-11 18:45:00.739 Status: dzVents: Debug: moon phase v1.01 for calouis: level switch selector : 10
2019-08-11 18:45:00.739 Status: dzVents: Debug: moon phase v1.01 for calouis: level name switch selector : Nouvelle lune
2019-08-11 18:45:00.740 Status: dzVents: Info: moon phase v1.01 for calouis: ------ Finished moonPhase
2019-08-11 18:45:02.003 Status: dzVents: Info: moonSelectorIcons v 1.0: ------ Start internal script: moonSelectorIcons: Device: "Lune (Virtuel)", Index: 194
2019-08-11 18:45:02.003 Status: dzVents: Debug: moonSelectorIcons v 1.0: lastLevel10
2019-08-11 18:45:02.003 Status: dzVents: Debug: moonSelectorIcons v 1.0: level40
2019-08-11 18:45:02.004 Status: dzVents: Debug: moonSelectorIcons v 1.0: http://127.0.0.1:8280/json.htm?type=setused&used=true&name=Lune&description=&idx=194&switchtype=18&customimage=109
2019-08-11 18:45:02.004 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: url = http://127.0.0.1:8280/json.htm?type=setused&used=true&name=Lune&description=&idx=194&switchtype=18&customimage=109
2019-08-11 18:45:02.004 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: method = GET
2019-08-11 18:45:02.004 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: post data = nil
2019-08-11 18:45:02.004 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: headers = nil
2019-08-11 18:45:02.004 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: callback = nil
2019-08-11 18:45:02.004 Status: dzVents: Info: moonSelectorIcons v 1.0: ------ Finished moonSelectorIcons
_ Raspberry Pi3 Stretch + Domoticz V4.11214
_ dzVents Version: 2.4.28
_ Python 3.5.3
_ usbZwave
_ RFX433XL USB Version: Pro XL1/1035
_ GW Xiaomi
_ station meteo Oregon & Netatmo
_ LMS
_ Yeelight
_ Tradfri
_ Zigate plugin 4.11.012 + Version : 031d
papoo
Messages : 2029 Inscription : 10 janv. 2016, 11:29
Localisation : Limoges (87)
Contact :
Message
par papoo » 11 août 2019, 18:57
ouf
samourai47
Messages : 286 Inscription : 04 déc. 2018, 19:44
Message
par samourai47 » 15 août 2019, 19:56
Hello
Question bete mais j'ai installé ce sprit en mode dzevents ALL
Le selector ne se met pas a jour alors que j'ai modifie l'IDX
Dois je installer dzevents ou c'est installé de base avec domoticz?
Merci d'avance
papoo
Messages : 2029 Inscription : 10 janv. 2016, 11:29
Localisation : Limoges (87)
Contact :
Message
par papoo » 15 août 2019, 19:59
C’est de base avec domoticz
Par contre c’est en mode Time qu’il faut l’installer
Vérifie quand même réglages / paramètres / Autre pour dzvents
samourai47
Messages : 286 Inscription : 04 déc. 2018, 19:44
Message
par samourai47 » 15 août 2019, 22:31
en fait dzevents etait desactivé dans parametre
merci