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.
papoo
Messages : 2029 Inscription : 10 janv. 2016, 11:29
Localisation : Limoges (87)
Contact :
Message
par papoo » 08 août 2019, 21:43
je viens de modifier mon script pour quil affichent les données de ton selecteur
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'
local MoonPhaseSelector = 2479--nil --
--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)
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
}
attention il s’exécute toutes les minutes penser à le mettre au moins toutes les heures après mise au point
calouis
Messages : 109 Inscription : 08 nov. 2015, 10:34
Localisation : 62
Message
par calouis » 08 août 2019, 21:48
Version: 4.11062
Build Hash: 77d4961e5
Compile Date: 2019-07-29 12:39:01
dzVents Version: 2.4.26
Python Version: 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516]
Je suis sur mac, éditeur "Sublime text 2". J'ai de nombreux scripts écrits avec cet éditeur, cela m'étonnerait que le pb est là.
D'autant qu'avec l'éditeur interne, le pb est le même !
code sélection manuelle :
Code : Tout sélectionner
2019-08-08 21:47:56.638 Status: dzVents: Info: moonSelectorIcons v 1.0: ------ Start external script: moonSelectorIcons.lua: Device: "Lune (Virtuel)", Index: 194
2019-08-08 21:47:56.639 Status: dzVents: Debug: moonSelectorIcons v 1.0: lastLevel70
2019-08-08 21:47:56.639 Status: dzVents: Debug: moonSelectorIcons v 1.0: level40
2019-08-08 21:47:56.639 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=160
2019-08-08 21:47:56.639 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=160
2019-08-08 21:47:56.639 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: method = GET
2019-08-08 21:47:56.639 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: post data = nil
2019-08-08 21:47:56.639 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: headers = nil
2019-08-08 21:47:56.639 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: callback = nil
2019-08-08 21:47:56.640 Status: dzVents: Info: moonSelectorIcons v 1.0: ------ Finished moonSelectorIcons.lua
2019-08-08 21:47:59.591 Status: dzVents: Info: moonSelectorIcons v 1.0: ------ Start external script: moonSelectorIcons.lua: Device: "Lune (Virtuel)", Index: 194
2019-08-08 21:47:59.591 Status: dzVents: Debug: moonSelectorIcons v 1.0: lastLevel40
2019-08-08 21:47:59.591 Status: dzVents: Debug: moonSelectorIcons v 1.0: level70
2019-08-08 21:47:59.591 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=163
2019-08-08 21:47:59.591 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=163
2019-08-08 21:47:59.591 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: method = GET
2019-08-08 21:47:59.591 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: post data = nil
2019-08-08 21:47:59.591 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: headers = nil
2019-08-08 21:47:59.591 Status: dzVents: Debug: moonSelectorIcons v 1.0: OpenURL: callback = nil
2019-08-08 21:47:59.592 Status: dzVents: Info: moonSelectorIcons v 1.0: ------ Finished moonSelectorIcons.lua
_ 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 » 08 août 2019, 21:54
essai la v1.01 voir l'etat du selecteur avant après stp
calouis
Messages : 109 Inscription : 08 nov. 2015, 10:34
Localisation : 62
Message
par calouis » 08 août 2019, 21:56
pas mieux, le switch ne change pas...
Code : Tout sélectionner
2019-08-08 21:50:00.455 Status: dzVents: Info: moon phase v1.0: ------ Start external script: moonPhase.lua:, trigger: every 5 minutes
2019-08-08 21:50:00.456 Status: dzVents: Debug: moon phase v1.0: 6.7088949999649
2019-08-08 21:50:00.456 Status: dzVents: Debug: moon phase v1.0: 6.7088949999649
2019-08-08 21:50:00.456 Status: dzVents: Debug: moon phase v1.0: Premier quartier
2019-08-08 21:50:00.456 Status: dzVents: Debug: moon phase v1.0: 30
2019-08-08 21:50:00.478 Status: dzVents: Debug: moon phase v1.0: Processing device-adapter for Lune: Switch device adapter
2019-08-08 21:50:00.478 Status: dzVents: Debug: moon phase v1.0: Constructed timed-command: Set Level 30
2019-08-08 21:50:00.480 Status: dzVents: Debug: moon phase v1.0: update selector device
2019-08-08 21:50:00.481 Status: dzVents: Info: moon phase v1.0: ------ Finished moonPhase.lua
2019-08-08 21:54:00.498 Status: dzVents: Info: moon phase v1.01: ------ Start external script: moonPhase.lua:, trigger: every minute
2019-08-08 21:54:00.498 Status: dzVents: Debug: moon phase v1.01: 6.7088949999649
2019-08-08 21:54:00.498 Status: dzVents: Debug: moon phase v1.01: 6.7088949999649
2019-08-08 21:54:00.498 Status: dzVents: Debug: moon phase v1.01: moon text : Premier quartier
2019-08-08 21:54:00.498 Status: dzVents: Debug: moon phase v1.01: level : 30
2019-08-08 21:54:00.521 Status: dzVents: Debug: moon phase v1.01: Processing device-adapter for Lune: Switch device adapter
2019-08-08 21:54:00.521 Status: dzVents: Debug: moon phase v1.01: switch selector name : Lune
2019-08-08 21:54:00.521 Status: dzVents: Debug: moon phase v1.01: switch selector id : 194
2019-08-08 21:54:00.521 Status: dzVents: Debug: moon phase v1.01: last level switch selector : 70
2019-08-08 21:54:00.521 Status: dzVents: Debug: moon phase v1.01: Constructed timed-command: Set Level 30
2019-08-08 21:54:00.521 Status: dzVents: Debug: moon phase v1.01: update selector device
2019-08-08 21:54:00.521 Status: dzVents: Debug: moon phase v1.01: level switch selector : 70
2019-08-08 21:54:00.521 Status: dzVents: Debug: moon phase v1.01: level name switch selector : Dernier quartier
2019-08-08 21:54:00.522 Status: dzVents: Info: moon phase v1.01: ------ Finished moonPhase.lua
2019-08-08 21:55:00.549 Status: dzVents: Info: moon phase v1.01: ------ Start external script: moonPhase.lua:, trigger: every minute
2019-08-08 21:55:00.549 Status: dzVents: Debug: moon phase v1.01: 6.7088949999649
2019-08-08 21:55:00.550 Status: dzVents: Debug: moon phase v1.01: 6.7088949999649
2019-08-08 21:55:00.550 Status: dzVents: Debug: moon phase v1.01: moon text : Premier quartier
2019-08-08 21:55:00.550 Status: dzVents: Debug: moon phase v1.01: level : 30
2019-08-08 21:55:00.572 Status: dzVents: Debug: moon phase v1.01: Processing device-adapter for Lune: Switch device adapter
2019-08-08 21:55:00.572 Status: dzVents: Debug: moon phase v1.01: switch selector name : Lune
2019-08-08 21:55:00.572 Status: dzVents: Debug: moon phase v1.01: switch selector id : 194
2019-08-08 21:55:00.572 Status: dzVents: Debug: moon phase v1.01: last level switch selector : 70
2019-08-08 21:55:00.572 Status: dzVents: Debug: moon phase v1.01: Constructed timed-command: Set Level 30
2019-08-08 21:55:00.572 Status: dzVents: Debug: moon phase v1.01: update selector device
2019-08-08 21:55:00.572 Status: dzVents: Debug: moon phase v1.01: level switch selector : 70
2019-08-08 21:55:00.572 Status: dzVents: Debug: moon phase v1.01: level name switch selector : Dernier quartier
2019-08-08 21:55:00.573 Status: dzVents: Info: moon phase v1.01: ------ Finished moonPhase.lua
_ 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 » 08 août 2019, 22:05
au vu de tes logs je dirai que dzvents bug avec la version beta que tu utilises . je ne vois pas d'autres explications.
essai via json
http://DOMOTICZ_IP:8080/json.htm?type=command¶m=switchlight&idx=194&switchcmd=Set%20Level&level=30
voir si le selector fonctionne
calouis
Messages : 109 Inscription : 08 nov. 2015, 10:34
Localisation : 62
Message
par calouis » 08 août 2019, 22:10
oui avec
Code : Tout sélectionner
http://IP:port/json.htm?type=command¶m=switchlight&idx=194&switchcmd=Set%20Level&level=30
j'ai :
sélecteur mise à jour !
Je dois faire une mise à jour de la beta?
_ 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 » 08 août 2019, 22:13
c'est toi qui vois
si cela ne te pose pas de pb fais le. sinon il faut modifier le script pour utiliser le json pour mettre à jour le selecteur
calouis
Messages : 109 Inscription : 08 nov. 2015, 10:34
Localisation : 62
Message
par calouis » 08 août 2019, 22:21
la mise à jour de la beta (cf signature) ne résout pas le pb...
_ 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 » 08 août 2019, 23:17
je viens de faire la mise à jour beta 4.11074
ça fonctionne chez moi.
as tu essayer de créer un autre selector sans icone juste avec 4 level minimum pour voir si cela ne viens pas du selecteur? en laissant les autres options par defaut?
calouis
Messages : 109 Inscription : 08 nov. 2015, 10:34
Localisation : 62
Message
par calouis » 08 août 2019, 23:30
J'essayerai demain.
Merci
A demain
_ 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