Page 3 sur 5

Re: Code lua pour notification Push

Publié : 06 déc. 2018, 14:26
par Wolfen38
Bonjour,

Comment fait on pour avoir dans le message une variable utilisateur ? Je n'arrive pas à trouver la syntaxe...

Merci.

Re: Code lua pour notification Push

Publié : 06 déc. 2018, 14:46
par Datawolf
Bonjour,

Voici un exemple de code

Code : Tout sélectionner

      local subsystem = "domoticz.NSS_PUSHBULLET"
                    --[[ Systèmes de notification disponibles :
                        NSS_GOOGLE_CLOUD_MESSAGING NSS_HTTP NSS_KODI NSS_LOGITECH_MEDIASERVER NSS_NMA NSS_PROWL NSS_PUSHALOT NSS_PUSHBULLET NSS_PUSHOVER NSS_PUSHSAFER
                        Pour une notification sur plusieurs systèmes, séparez les systèmes par une virgule.
                        Exemple :{domoticz.NSS_TELEGRAM, domoticz.NSS_HTTP}
                    --]]

        variable = uservariables['MaVariableUtilisateur']

        domoticz.notify('Titre', 'contenu='..variable, domoticz.PRIORITY_HIGH, ' ', ' ', subsystem)                                    
Au passage tu as aussi:

Code : Tout sélectionner

        domoticz.email('Titre', 'contenu='..variable, 'monadresse@gmail.com')
@+
Datawolf

Re: Code lua pour notification Push

Publié : 06 déc. 2018, 14:50
par Wolfen38
Merci, mais c'est la synthaxe que je ne trouve pas.

Pour le moment j'ai :

Code : Tout sélectionner

if time.hour == 14 and time.min == 45
               then
                  commandArray[#commandArray+1] = {['SendNotification'] = 'Waze # ..(string.format("%g",tostring(uservariables['Trajet-retour'])))..'°C' #0###pushover'}
         end
Mais ca ne fonctionne pas.

Re: Code lua pour notification Push

Publié : 06 déc. 2018, 15:18
par Wolfen38
J'ai essayé ca en partant de ton extrait :

Code : Tout sélectionner

commandArray = {}
 
if time.hour == 15 and time.min == 15
               then                       
local subsystem = "domoticz.NSS_PUSHOVER"
                    --[[ Systèmes de notification disponibles :
                        NSS_GOOGLE_CLOUD_MESSAGING NSS_HTTP NSS_KODI NSS_LOGITECH_MEDIASERVER NSS_NMA NSS_PROWL NSS_PUSHALOT NSS_PUSHBULLET NSS_PUSHOVER NSS_PUSHSAFER
                        Pour une notification sur plusieurs systèmes, séparez les systèmes par une virgule.
                        Exemple :{domoticz.NSS_TELEGRAM, domoticz.NSS_HTTP}
                    --]]
        variable = uservariables['Trajet-retour']
        domoticz.notify('Waze', 'contenu='..variable, domoticz.PRIORITY_HIGH, ' ', ' ', subsystem)                                    
end

return commandArray
Mais dans les log j'ai ca "2018-12-06 15:17:54.531 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_waze-notification2.lua: ...omoticz/scripts/lua/script_device_waze-notification2.lua:7: attempt to index global 'time' (a nil value)"

Re: Code lua pour notification Push

Publié : 06 déc. 2018, 15:44
par Datawolf

Code : Tout sélectionner

time = os.date("%H:%M")
if time == '15:15'
               then   

Re: Code lua pour notification Push

Publié : 06 déc. 2018, 15:58
par Wolfen38
Merci on progresse main maintenant j'ai ca : "2018-12-06 15:55:30.051 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_waze-notification2.lua: ...omoticz/scripts/lua/script_device_waze-notification2.lua:17: attempt to index global 'domoticz' (a nil value)"

sur mon code :

Code : Tout sélectionner

time = os.date("%H:%M")



 
commandArray = {}
 
if time == '15:55'
               then                        
local subsystem = "domoticz.NSS_PUSHOVER"
                    --[[ Systèmes de notification disponibles :
                        NSS_GOOGLE_CLOUD_MESSAGING NSS_HTTP NSS_KODI NSS_LOGITECH_MEDIASERVER NSS_NMA NSS_PROWL NSS_PUSHALOT NSS_PUSHBULLET NSS_PUSHOVER NSS_PUSHSAFER
                        Pour une notification sur plusieurs systèmes, séparez les systèmes par une virgule.
                        Exemple :{domoticz.NSS_TELEGRAM, domoticz.NSS_HTTP}
                    --]]
        variable = uservariables['Trajet-retour']
        domoticz.notify('Waze', 'contenu='..variable, domoticz.PRIORITY_HIGH, ' ', ' ', subsystem)                                    
end

return commandArray

Re: Code lua pour notification Push

Publié : 06 déc. 2018, 20:26
par Datawolf
Que dirais-tu d'un dzVents ?

Code : Tout sélectionner

return {
   on = {
             timer = {  'at 15:15', },
          }
   execute = function(domoticz, timer)   
      local subsystem = "domoticz.NSS_PUSHOVER"
--[[ Systèmes de notification disponibles :
                        NSS_GOOGLE_CLOUD_MESSAGING NSS_HTTP NSS_KODI NSS_LOGITECH_MEDIASERVER NSS_NMA NSS_PROWL NSS_PUSHALOT NSS_PUSHBULLET NSS_PUSHOVER NSS_PUSHSAFER
                        Pour une notification sur plusieurs systèmes, séparez les systèmes par une virgule.
                        Exemple :{domoticz.NSS_TELEGRAM, domoticz.NSS_HTTP}
--]]
      variable = uservariables['Trajet-retour']
      domoticz.notify('Waze', 'contenu='..variable, domoticz.PRIORITY_HIGH, ' ', ' ', subsystem)                                    
   end
}

Re: RE: Re: Code lua pour notification Push

Publié : 06 déc. 2018, 20:29
par Wolfen38
Datawolf a écrit :Que dirais-tu d'un dzVents ?

Code : Tout sélectionner

return {
   on = {
             timer = {  'at 15:15', },
          }
   execute = function(domoticz, timer)   
      local subsystem = "domoticz.NSS_PUSHOVER"
--[[ Systèmes de notification disponibles :
                        NSS_GOOGLE_CLOUD_MESSAGING NSS_HTTP NSS_KODI NSS_LOGITECH_MEDIASERVER NSS_NMA NSS_PROWL NSS_PUSHALOT NSS_PUSHBULLET NSS_PUSHOVER NSS_PUSHSAFER
                        Pour une notification sur plusieurs systèmes, séparez les systèmes par une virgule.
                        Exemple :{domoticz.NSS_TELEGRAM, domoticz.NSS_HTTP}
--]]
      variable = uservariables['Trajet-retour']
      domoticz.notify('Waze', 'contenu='..variable, domoticz.PRIORITY_HIGH, ' ', ' ', subsystem)                                    
   end
}
Je ne connais pas du tout ce genre de programmation ça fait pas longtemps que j'ai découvert le lua.

Ça se met ou ce fichier ? Y a un répertoire spécial comme pour les lua ?

Envoyé de mon Mi A1 en utilisant Tapatalk


Re: Code lua pour notification Push

Publié : 06 déc. 2018, 20:39
par Datawolf
Si tu as créé un sous-répertoire dans domoticz/scripts pour tes lua alors fais de même pour les dzvents.
Sinon tu les mets directement dans scripts.
Ou plus simplement, dans l'interface: Réglages>Plus d'options>Événements. ;)

Re: RE: Re: Code lua pour notification Push

Publié : 06 déc. 2018, 20:45
par Wolfen38
Datawolf a écrit :Si tu as créé un sous-répertoire dans domoticz/scripts pour tes lua alors fais de même pour les dzvents.
Sinon tu les mets directement dans scripts.
Ou plus simplement, dans l'interface: Réglages>Plus d'options>Événements. ;)
Dans réglages, plus d'option, événement, c'est les blocky pas les dzevent ?

Envoyé de mon Mi A1 en utilisant Tapatalk