Code lua pour notification Push

Forum dédié aux problématiques concernant les scripts pour DomoticZ.
Entourez votre code et les logs avec les balises nommées code grâce au bouton <\>.
Wolfen38
Messages : 1983
Inscription : 19 oct. 2017, 14:49

Re: Code lua pour notification Push

Message par Wolfen38 »

Bonjour,

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

Merci.
Datawolf
Messages : 273
Inscription : 03 avr. 2018, 13:51

Re: Code lua pour notification Push

Message 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
Wolfen38
Messages : 1983
Inscription : 19 oct. 2017, 14:49

Re: Code lua pour notification Push

Message 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.
Wolfen38
Messages : 1983
Inscription : 19 oct. 2017, 14:49

Re: Code lua pour notification Push

Message 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)"
Datawolf
Messages : 273
Inscription : 03 avr. 2018, 13:51

Re: Code lua pour notification Push

Message par Datawolf »

Code : Tout sélectionner

time = os.date("%H:%M")
if time == '15:15'
               then   
Wolfen38
Messages : 1983
Inscription : 19 oct. 2017, 14:49

Re: Code lua pour notification Push

Message 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
Datawolf
Messages : 273
Inscription : 03 avr. 2018, 13:51

Re: Code lua pour notification Push

Message 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
}
Wolfen38
Messages : 1983
Inscription : 19 oct. 2017, 14:49

Re: RE: Re: Code lua pour notification Push

Message 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

Datawolf
Messages : 273
Inscription : 03 avr. 2018, 13:51

Re: Code lua pour notification Push

Message 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. ;)
Wolfen38
Messages : 1983
Inscription : 19 oct. 2017, 14:49

Re: RE: Re: Code lua pour notification Push

Message 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

Répondre