-
Compteur de contenus
100 -
Inscription
-
Dernière visite
-
Jours gagnés
5
Tout ce qui a été posté par drboss
-
Merci @pepite Je rattrape le temps quand je n'avais aucun accès à HC2. ( Des chirurgiens opéraient ma colonne vertébrale ;-( Et je n'ai pas eu accès à l'ordinateur, juste un téléphone :-((((((((
-
I have confirmation from Fibaro that "httpClient:request(url..." blocks handle until the scene is over not to end of called http work and /api/service/backups/'..id can only be launched once at the same time. Therefore, to delete more than one file, you must call the external scene who delete backups In this case I updated code of backup-delete.lua and added backup-batch. All necessary parameters are passed automatically to backup-batch.lua, You only need edit parameters in backup-create.lua and backup-delete.lua. I added for batch process NotificationService with popups on web page like in situation with to many scenes run at same time backup-batch.lua backup-delete.lua backup-create.lua
-
I have "small" problem, when in run backup_delate.lua. If I have more that 1 backup to delete in one run, script delete only one backup (oldest - it's ok) from selected by criteria for deletion (red debug info) for other chosen backup HC2 return error 404. For delete next one and next (if exist) I need rerun the scene. But if I create for function deleteBackup(id) separate scene and I call it with parameter (id) from backup_delete.lua of course with sleep(45) between the next ID all work fine. ..//.. if... then fibaro:startScene(999, {{id_del = backups['id']}}) fibaro:sleep(45) end ..//.. For me is look like situation when backup_delate.lua block called http://127.0.0.1/api/service/backups/'..id until the scene end. Any from You have the same problem? Any idea?
-
Sorry for post in english and text in scenes, but it's faster to write for me. I need my modification because of many (biggest or smallest) problem each time when I upgrade HC2 with new firmware. And the problem not happen direct after upgrade, but hours or days after (like my last problem with corrupt z-wave databases or 503 error after restart) . For restore backup when I have 503 error without chance to login I use REST client for POST http://HC2IP/api/service/backups/ with payload {"action":"restore","params":{"id":928}}. "id" I take form GET http://HC2IP/api/service/backups Small modification of backup and delete: 1. Autodelete only autobackup (created by backup_store.lua scene) 2. Autodelete no oldest backup but delete backups by days from today. Note: Scenes not use any variables stored in HC2, they parse data by backup destricption In backup_store.lua you have this new parameters: backup_symbol = '!' -- this symbol is added on beginning of description on backup time. Scenes use this for identify autobackup and for not delete manual or upgrade time backups without this symbol (in example on attached printscreen I use ‘p’ on place of '!') backup_stay = '025' -- days for store backup from 001 to 999 days (obligatory with loading zeros). When for ex. you change this parameters for 1 backup from 030 to 025 and after this return to 030, only this one have different store time from another backups. In backup_delete.lua backup_symbol = '!' -- most important to be same to backup_symbol defined in backup_store.lua default_stay = 'no' -- use individual backup store time from description. Set 'yes' if you decide to ignore individual time to store backup defined in backup__store.lua and registered in backup description backup_stay = '030' -- if you decide to set default_stay to 'yes' backup_delete.lua use this for check number of day after witch the backup will be delete. The backup_delete.lua use this parameter too for backup with description who start by '!' but without [NNN] for number of store day (ex. for temporary backup created manually, they be delete after this number of day) Structure of backup description used by scenes: ![025] any character/any text ! - first symbol identify backup created and used by scenes, obligatory for treatment by this two scenes [025] - number of days for store backup, not obligatory, if not exist the backup_stay defined in backup_delete.lua are used. backup_delate.lua --[[ %% properties %% events %% globals --]] -- Flag dryrun; Si true, la requete sur api pour effacer le backup n'est pas effectuée local dryrun = true --[[ modification to delete only backup file created by autobackup scene (selected by '!' in descrption on first positon) and oldes more that 90 days Backups created manualy (without '!') are not deleted by this scene --]] local backup_stay = 10 -- time in day for store autobackup file if not use time in description ore no time in description local default_stay = 'no' -- if 'yes' use [backup_stay] for all autobackup file, if 'no' use number of days stored in desciption of backup local backup_symbol = '!' -- only delete after day stored in [backup_time] backup with this symbol on first postion in decription text. Need the same as in auto backup scene -- Password admin encodé en base64 local password = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' print('Current parameters:') print('only backups with description start by ['..backup_symbol..'] are processed') print('and deleted after: '..backup_stay..' day(s) if not dedicated information in description') if default_stay == 'yes' then print('Number of days for store backup is overwriten by '.. tostring(backup_stay) ..' day(s)') end function sortBackup(data) local backups = json.decode(data) -- Vérification de présence Backup if (backups and type(backups == 'table') and #backups > 0) then if #backups > 1 then print(#backups .. ' Backups présents') else print('1 Backup présent') end for i in ipairs(backups) do --fibaro:debug('<font color="red">ID: '..backups[i]['id']..' | TIME: '..os.date("%Y/%m/%d %H:%M:%S", backups[i]['timestamp'])..' | DESCRIPTION: '..backups[i]['description']) --print(os.date("%Y/%m/%d %H:%M:%S", backups[i]['timestamp'])) --print(os.time()) --print(os.time() - tonumber(backups[i]['timestamp'])) delta=os.time() - tonumber(backups[i]['timestamp']) todelete=string.sub(backups[i]['description'],1,1) -- =='!' if default_stay == 'no' and string.sub(backups[i]['description'],2,2) == '[' then -- obsłużyć gdy nie trafi na [] backup_stay_tmp=tonumber(string.sub(backups[i]['description'],3,5)) else backup_stay_tmp=backup_stay end -- print(tostring(backup_stay_tmp)..string.sub(backups[i]['description'],2,2)) -- print(string.sub(backups[i]['description'],1,1)) -- =='!' if delta <= backup_stay_tmp*60*60*24 and (string.sub(backups[i]['description'],1,1)) == backup_symbol then fibaro:debug('<font color="orange">ID: '..backups[i]['id']..' | TIME: '..os.date("%Y/%m/%d %H:%M:%S", backups[i]['timestamp'])..' | DESC: '..backups[i]['description']) fibaro:debug("^^^ To delete in ".. backup_stay_tmp-tostring(math.floor(delta/60/60/24)).." day from today ^^^") elseif delta > backup_stay_tmp*60*60*24 and (string.sub(backups[i]['description'],1,1)) == backup_symbol then fibaro:debug('<font color="red">ID: '..backups[i]['id']..' | TIME: '..os.date("%Y/%m/%d %H:%M:%S", backups[i]['timestamp'])..' | DESC: '..backups[i]['description']) print("^^^ Deleted this time ^^^") deleteBackup(backups[i]['id']) else fibaro:debug('<font color="green">ID: '..backups[i]['id']..' | TIME: '..os.date("%Y/%m/%d %H:%M:%S", backups[i]['timestamp'])..' | DESC: '..backups[i]['description']) end end else print('Pas de backup ou erreur lors de la récupération de la liste') fibaro:abort() end -- Pour chaque Backup on stock le timestamp de la date de réalisation dans une table -- On classe ensuite les timestamps par ordre croissant local timestamp = {} for i in ipairs(backups) do table.insert(timestamp, backups[i]['timestamp']) end table.sort(timestamp) -- Le 1er timestamp de la table est le plus petit donc le plus ancien en epochtime -- Dans la table de backup on recherche le backup ayant ce timestamp --[[ local id = false for i in ipairs(backups) do if (tonumber(backups[i]['timestamp']) == tonumber(timestamp[1])) then id = backups[i]['id'] end end if id then print("ID du backup le plus ancien: "..id) deleteBackup(id) else print("Erreur lors de la récupération de l'ID") fibaro:abort() end --]] end function deleteBackup(id) -- Requete via API pour effacer le backup le plus ancien if (not dryrun) and (id) then print('Effacement du backup '..id..' en cours. Cela peut prendre 30s') local url = 'http://127.0.0.1/api/service/backups/'..id local httpClient = net.HTTPClient() httpClient:request(url , { success = function(response) if tonumber(response.status) == 200 then print("Backup deleted at " .. os.date()) else print("Error " .. response.status) end end, error = function(err) print('error = ' .. err) end, options = { method = 'DELETE', headers = { ["content-type"] = 'application/x-www-form-urlencoded;', ["authorization"] = 'Basic '..password }, data = 'id='..id } }) end end -- Récupération de la list des backups local GETClient = net.HTTPClient() if dryrun then print('Mode DryRun -> La requète pour effacer ne sera pas éxécutée') end GETClient:request('http://127.0.0.1/api/service/backups', { success = function(response) if tonumber(response.status) == 200 then sortBackup(response.data) else print("Error " .. response.status) end end, error = function(err) print('error = ' .. err) end, headers = { ["content-type"] = 'application/x-www-form-urlencoded;', ["authorization"] = 'Basic '..password } }); backup_store.lua --[[ %% properties %% events %% globals --]] -- ID des mobiles,tablettes pour notification local portable = { 892 } local backup_symbol = '!' -- for auto delete only backups with this symbol on irst postion in description local backup_stay = '025' -- numbers of days to store autobackups (from 001 to 999 with loading zeros) print('Current parameters:') print('delete after: '..backup_stay..' day(s), only backups with description start by ['..backup_symbol..']') fibaro:sleep(10*1000) function sendPush(message) if #portable > 0 then for _,v in ipairs(portable) do fibaro:call(v,'sendPush', message) end end end -- Message Descriptif du Backup local descriptif = backup_symbol..'['..backup_stay..'] Autobackup - '..os.date("%d/%m/%y - %HH%M") -- Password admin encodé en base64 local password = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' local url = 'http://127.0.0.1/api/service/backups' local datas = '{"action":"create","params":{"name":"'..descriptif..'"}}' local httpClient = net.HTTPClient() httpClient:request(url , { success = function(response) if tonumber(response.status) == 201 or tonumber(response.status) == 202 then print("Backup Created at " .. os.date()) sendPush(descriptif .. ' effectué') else print("Error " .. response.status) sendPush('Erreur lors de la création du Backup - '.. response.status) end end, error = function(err) print('error = ' .. err) end, options = { method = 'POST', headers = { ["content-type"] = 'application/json', ["Authorization"] = 'Basic '..password }, data = datas } }); on image backup2 parameter dryrun = true on image backup3 parameter dryrun = false
-
@ericl78 no... en version 9.9999 code secret de HC2 version = version + 0.001 if version < 9.999 then call funcion(minimum_1_error_creation) end if version >= 9.999 then call funcion(randomly_1_error_remove) end ...
-
#!/bin/ash ############## # add this script to crontab of your router or any linux machine # i use openwrt router with sendmail, curl packages # */15 * * * * /scripts/hc2watchdog ############## set -e # IP of HC2 HCIP="192.168.1.n" # login string for HC2 HCLOG="admin@domain.pl:password" # email from mserver="mail.mail.pl" muser="hc2@domain.pl" mpass="password" # email to memail="user@domain.pl" status_www=`curl -N -I --user $HCLOG $HCIP/api/settings/info 2>/dev/null | head -n 1` echo $status_www status_server=`curl -N --user $HCLOG $HCIP/api/refreshStates 2>/dev/null | head -n 1 | cut -d',' -f1 | cut -d "{" -f2` status_time=`curl -N --user $HCLOG $HCIP/api/refreshStates 2>/dev/null | head -n 1 | cut -d',' -f3` echo "HC2 response:" echo "===============================" echo $status_server echo $status_time case "$status_server" in *status*) echo "HC2 working" echo $status_time exit ;; esac echo "Problem..." # send syslog message to my syslog server, put hash begin of next line if you not use logger "HC2 - restart $status_server" -p authpriv.alert -t HC2 echo "HC2 restart..." curl --user $HCLOG http://$HCIP/services/finishUpgradeAfterError.php # send email to you after restart, put hash begin of next line if you not use mailsend -smtp $mserver -port 587 -auth -user $muser -pass $mpass -starttls -f dom@durbajlo.email -name "HC2 watchdog" -t $memai echo "HC2 status " $status_server > /tmp/hc2.status echo "HC2 - oczekiwanie na restart" sleep 60s echo "HC2 - check after restart" echo "================================" status_www=`curl -N -I --user $HCLOG $HCIP/api/settings/info 2>/dev/null | head -n 1` echo $status_www status_server=`curl -N --user $HCLOG $HCIP/api/refreshStates 2>/dev/null | head -n 1 | cut -d',' -f1 | cut -d "{" -f2` status_time=`curl -N --user $HCLOG $HCIP/api/refreshStates 2>/dev/null | head -n 1 | cut -d',' -f3` echo $status_server echo $status_time Parce que, dans la version 4133 sont les mêmes erreurs que dans la version précédente, j'ai écrit un script pour redémarrer automatiquement de l'extérieur ma HC2 en cas d'erreur 503 ou d'un serveur interne de HC2. Tout en anglais à https://forum.fibaro.com/index.php?/topic/26127-external-watchdog-for-hc2/
-
Je inclus cette fois normal, parce que je voulais tester rapidement. Apres premier démarre le moteur lui-même calibrer. Mais il est possible en changeant le paramètre 12 à 2 et à nouveau à 1 sur HC2 ou par boutons sur le motour. Dessous l'instruction, mais pas encore approuvé par Fakro, mais la description est correcte ZWS12n.pdf
-
No sans templete J'ai parlé avec un ingénieur de Fakro (responsable du produit) Il ma dit que tout remis à Fibaro e ils attendent . Ils ont le problème similaire que nous clients avec des retards chez Fibaro avec implementation de template. Aujourd'hui, il est prévu pour la prochaine version stable. mais je ne crois pas... c'est Fibaro :-) Mais pour les 5 paramètres, je pense que n'a pas besoin tempate. Et voila, moteur est monté et opérationnel...
-
Je l'ai testé une nouvelle version (v1.1) du moteur pour les fenêtres Fakro. Précédent version (v1) avec HC2 a permis que la fermeture ou l'ouverture a 100%. Nouvelle permet toute position - ferme, ouver 1-100% et fermeture par la pluie. Vous pouvez commander la version avec capteur de pluie (voir photo) ou sans. Version avec capteur de pluie aujourd'hui uniquement par email chez Fakro. Ce module peut contrôler directement les autres 5 moteurs sans détecteur (par groupe association nr 4). J'ai installé sans problem les 3 moteurs aux fenêtres et Velux et Fakro. Ils travaillent déjà trois semaines. Remarque. Sur Internet sont disponibles les anciennes versions de ZWS12 ou ZWS230 (v1), nouveaux moteurs sont marqués ZWS12n ou ZWS230n. Et si quelqu'un est intéressé devrait commander à Fakro. Le prix est 200 euros Voici les paramètres de configuration: No. Value Default Value Description 7 1234 1 Motor speed I 8 1234 2 Motor speed II (rain sensor) 12 12 1 Value 1 – calibrated Value 2 – discalibrated – to enter the calibration mode must first time discalibrate and then calibrate. 13 12 1 1 – FF go to Max 2 – FF go to previous position 15 0-255 0 Close after time (mn) Notyfication type: Event Water Alarm: Water Leak detected, Unknow Location Power Management: Over-load detected Association Groups: 1. Life Line – group for position reporting actuator after each a stoppage and alarm reporting (overcurrent, damage encoders). This group can be a maximum 1 device. 2. Basic Repeat – group used to transfer the received basic commands to the devices included in this group. This group can be a maximum 5 devices. 3. Multilevel Repeat – group used to transfer the received multilevel commands to the devices included in this group. This group can be a maximum 5 devices. 4. Basic Rain – group used to transfer the received commands from actuator & rain detector to the devices included in this group. This group can be a maximum 5 devices.
-
Je pense que je avais des la même situation il y a un mois. J'ai perdu beaucoup de temps pour trouver une erreur.Comme je l'ai regardé le journal le problème était dans la table arp. Je ne sais pas pourquoi SONOS parfois mal et stocke l'adresse IP avec l'ARP. Il enregistrer l'adresse MAC de l'appareil normalement et aussi avec le début de 9a: de: d0. ex. 192.168.1.232 b8:e9:37:dd:ab:56 et deziem deuxième 9a: de: d0:dd:ab:56 Je ne l'ai pas eu le temps d'analyser, parce que le réseau entier est bloqué, et a la fin je suis retourné au réseau indépendant SONOS de mon WiFi.
-
Check if in Your code exist many ", because You need use it only on begin & end of string on LUA level. In string (html) You need use " for " < for < etc... I have this problem when I past code first time to forum. The forum convert html &... to normal character when You not change typ of source. I doing concretion on 28.03, please check this in Your VD or paste this que: que = function() return sendSoapMessage( -- control url "/MediaRenderer/AVTransport/Control", -- service type "urn:schemas-upnp-org:service:AVTransport:1", -- action { name = "AddURIToQueue", service = "urn:schemas-upnp-org:service:AVTransport:1" }, -- soap body data (options) "<InstanceID>0</InstanceID>,<EnqueuedURI>file:///jffs/settings/savedqueues.rsq#"..list_nbr.."</EnqueuedURI>,<EnqueuedURIMetaData><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="SQ:1" parentID="SQ:" restricted="true"><dc:title>"..list_name.."</dc:title><upnp:class>object.container.playlistContainer</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">RINCON_AssociatedZPUDN</desc></item></DIDL-Lite></EnqueuedURIMetaData>,<DesiredFirstTrackNumberEnqueued>1</DesiredFirstTrackNumberEnqueued>,<EnqueueAsNext>1</EnqueueAsNext>", -- callback (options) function(response) fibaro:debug("que"); end); end
-
You need to the test, for ex. I have list of 9 playlist (see image bellow). The Sonos sort in application list by alphabet, but for the list give number by sequence of addition. In my example last added list is playlist SAUNA and they have number 9 I haven't the time for write the request for retrieve the list with number and name for for display in debug window. But is more simple when you use spotify with sonos. spotify_user - your spotify login used in sonos spotify_playlist - the id of playlist in spotify retrived like album id from spotify www - see first post. que = function() --playlist from Spotify return sendSoapMessage( -- control url "/MediaRenderer/AVTransport/Control", -- service type "urn:schemas-upnp-org:service:AVTransport:1", -- action { name = "AddURIToQueue", service = "urn:schemas-upnp-org:service:AVTransport:1" }, -- soap body data (options) "<InstanceID>0</InstanceID>,<EnqueuedURI>x-rincon-cpcontainer:10062a6cspotify%3auser%3a"..spotify_user.."%3aplaylist%3a"..spotify_playlist.."</EnqueuedURI>,<EnqueuedURIMetaData><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="10062a6cspotify%3auser%3a"..spotify_user.."%3aplaylist%3a"..spotify_playlist.."" parentID="10082664playlists" restricted="true"><dc:title>Fibaro from Spotify</dc:title><upnp:class>object.container.playlistContainer</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON2311_X_#Svc2311-0-Token</desc></item></DIDL-Lite></EnqueuedURIMetaData>,<DesiredFirstTrackNumberEnqueued>2</DesiredFirstTrackNumberEnqueued>,<EnqueueAsNext>1</EnqueueAsNext>", -- callback (options) function(response) fibaro:debug("que"); end); end ----
-
Merci @Lazer Je ne l'ai pas trouvé le sujet, ma faute je ne l'ai pas regardé dans le BISTRO :-( Donc, nous attendons et voyons
-
C'est intéressant https://www.qnap.com/en/news/2017/qnap-starts-cooperation-with-fibaro-providing-a-feature-packed-hub-for-smart-home-systems Questions: 1. Avec quel Z-wave USB fonctionnera? 2. Quelle série QNAP? 3. Quel est le prix du logiciel Fibaro?
-
Chez moi, après l'utilisation de le patch @Titof_44 et l'exécution de la commande httpClient:request("http://127.0.0.1:11111/api/sceneControl?id="..id.."&action=start") la commande fibaro:debug(fibaro:countScenes(id)) retourne 0, mais la scène fonctionne correctement. Bien sûr, Watchdog avec "0" redémarre la scène tout le temps Si la scène arrêté et redemarre par slide bouton fibaro:countScenes(id) returne bien 1 Pourquoi???
-
Merci @Krikroff
- 478 réponses
-
- tuto hc2 et hcl
- toolkit
- (et 4 en plus)
-
To play any album from Spotify (of corse spotify account exist on Sonos) I use this code, the id of album I take by spotify app for window (left mouse button on album image and from menu "copy id URI Spotify", take only the string after second ':') allbum ="ID URI SPOTIFY" ..//.. clear_last_que = function() -- without this album is added after play song/query return sendSoapMessage( -- control url "/MediaRenderer/Queue/Control", -- service type "urn:schemas-sonos-com:service:Queue:1", -- action { name = "RemoveAllTracks", service = "urn:schemas-sonos-com:service:Queue:1" }, -- soap body data (options) "<QueueID>0</QueueID>,<UpdateID>0</UpdateID>", -- callback (options) function(response) fibaro:debug("Remove"); end); end que_spotify_album = function() --album from Spotify return sendSoapMessage( -- control url "/MediaRenderer/AVTransport/Control", -- service type "urn:schemas-upnp-org:service:AVTransport:1", -- action { name = "AddURIToQueue", service = "urn:schemas-upnp-org:service:AVTransport:1" }, -- soap body data (options) "<InstanceID>0</InstanceID>,<EnqueuedURI>x-rincon-cpcontainer:1004206cspotify%3aalbum%3a"..album.."</EnqueuedURI>,<EnqueuedURIMetaData><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="1004206cspotify%3aalbum%3a"..album.."" parentID="100d2064your_albums" restricted="true"><dc:title>Remote</dc:title><upnp:class>object.container.album.musicAlbum</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON2311_X_#Svc2311-0-Token</desc></item></DIDL-Lite></EnqueuedURIMetaData>,<DesiredFirstTrackNumberEnqueued>2</DesiredFirstTrackNumberEnqueued>,<EnqueueAsNext>1</EnqueueAsNext>", -- callback (options) function(response) fibaro:debug("que"); end); end ..//.. clear_last_que() que_spotify_album(); playFile(FileVol);
-
@Krikroff Sorry but this time I ask in english Is there a simple command to call the defined playlist? Eg. by replacing cmd in radio5 button I didn't fine solution on forum, maybe exist ... And I doing it (today night my children with wife going to my parents and I have time). Play by VD of playlist work. I use old (2014) LUA script of @Krikroff (I things). In this time without retrieve of playlist name. Only work by id of playlist, Please if wont test it on yours Sonos systems. My work is not big, the code is by @KrikroffI only do the small adaptation and add command of Sonos for play list. The version is not optimized and very professional because I doing it fast for me. I will use it for button and scene of sauna controller ;-) -- SONOS Play playlist, v.0.1 ------------------------------------------------------------------------------------------- ---made on source of:----------------------------------------------------------------------- -- SONOS Play stream... -- Copyright © 2014 Jean-Christophe Vermandé ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- ---------------------------------- -- User Settings ---------------------------------- ip = "192.168.1.232" port = 1400 FileVol = 10 PlayUnlimited = "Yes" -- si <> Yes, arrêt après 30s environ --duration = ---------------------------------- -- DO not change bellow this line ---------------------------------- selfId = fibaro:getSelfId(); --ip = fibaro:get(selfId, 'IPAddress'); --port = fibaro:get(selfId, 'TCPPort') or 1400; currentTransportState = ""; lastTransportState = ""; currentVolume = 0; lastVolume = 0; ttsVolumeIsDifferent = false; list_name = "Sonos Playlist n1" --not implemented list_nbr = 1 -- playlist number on jffs system of SONOS, You need test it for find interesting list uid = "RINCON_B8E937B01D4E01400" -- find by http://SONOS_IP:1400/status/upnp urlencode = function(str) if (str) then str = string.gsub (str, "\n", "\r\n"); str = string.gsub (str, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end); str = string.gsub (str, " ", "+"); end return str; end createRequestBody = function(action, schema, data) return string.format("<u:%s xmlns:u=\"%s\">%s</u:%s>", action, schema, data, action); end reponseCallback = function(fnc, args) if (fnc == nil) then return nil; end return fnc(args); end createSocket = function() -- Check IP and PORT before if (ip == nil or port == nil) then fibaro:debug("You must configure IPAddress and TCPPort first"); return; end local socket; local status, err = pcall(function() socket = Net.FTcpSocket(ip, port); socket:setReadTimeout(1000); end); if (status ~= nil and status ~= true) then fibaro:debug("socket status: " .. tostring(status or '')); end if (err ~= nil) then fibaro:debug("socket err: " .. tostring(err or '')); return; end return socket; end disposeSocket = function(socket) if (socket ~= nil) then socket:disconnect(); socket = nil; return true; end return false; end sendSoapMessage = function(url, service, action, args, callback, retry) local socket = createSocket(); if (socket == nil) then return; end retry = retry or 0 -- prepare data local url = "POST " .. url .. " HTTP/1.1"; --local udn = "X-SONOS-TARGET-UDN: uuid:RINCON_B8E937B01D4E01400" -- udn of my SONOS (not need) local soapaction = "SOAPACTION: \"" .. service .. "#" .. action.name .. "\""; local body = createRequestBody(action.name, action.service, tostring(args or "")); local envelope = "<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body>" .. body .. "</s:Body></s:Envelope>"; local ctl = "Content-Length: " .. string.len(envelope); --local payload = url .. "\r\n" .. ctl .. "\r\n" .. udn .. "\r\n" .. soapaction .. "\r\n" .. "\r\n" .. envelope; -- with UDN local payload = url .. "\r\n" .. ctl .. "\r\n" .. soapaction .. "\r\n" .. "\r\n" .. envelope; -- write data local bytes, errorcode = socket:write(payload); if (errorcode == 0) then local state, errorcode = socket:read(); if (errorcode == 0) then if (string.len(state or "") > 0) then -- callback if (callback ~= nil) then reponseCallback(callback, state); end -- dispose ... disposeSocket(socket); return true; else fibaro:debug("Error: Invalid response. response length: " .. string.len(state or "")); end else if (retry < 5) then fibaro:debug("retry #"..retry.." action: " .. action.name); return sendSoapMessage(url, service, action, args, callback, (retry + 1)); else fibaro:debug("Error: Code returned "..tostring(errorcode or "")); end end elseif (errorcode == 2) then fibaro:debug("Error: You must check your IP and PORT settings."); else if (retry < 5) then fibaro:debug("retry #"..retry.." action: " .. action.name); return sendSoapMessage(url, service, action, args, callback, (retry + 1)); else fibaro:debug("Error: Code returned "..tostring(errorcode or "")); end end -- dispose ... disposeSocket(socket); -- default response return false; end stop = function() return sendSoapMessage( -- control url "/MediaRenderer/AVTransport/Control", -- service type "urn:schemas-upnp-org:service:AVTransport:1", -- action { name = "Stop", service = "urn:schemas-upnp-org:service:AVTransport:1" }, -- soap body data (options) "<InstanceID>0</InstanceID><Speed>1</Speed>", -- callback (options) function(response) fibaro:debug("stop sent"); end); end unMute = function() return sendSoapMessage( -- control url "/MediaRenderer/RenderingControl/Control", -- service type "urn:schemas-upnp-org:service:RenderingControl:1", -- action { name = "SetMute", service = "urn:schemas-upnp-org:service:RenderingControl:1" }, -- soap body data (options) "<InstanceID>0</InstanceID><Channel>Master</Channel><DesiredMute>0</DesiredMute>", -- callback (options) function(response) fibaro:debug("unMute sent"); end); end play = function(duration) return sendSoapMessage( -- control url "/MediaRenderer/AVTransport/Control", -- service type "urn:schemas-upnp-org:service:AVTransport:1", -- action { name = "Play", service = "urn:schemas-upnp-org:service:AVTransport:1" }, -- soap body data (options) "<InstanceID>0</InstanceID><Speed>1</Speed>", -- callback (options) function(response) if (duration ~= nil) then fibaro:debug("play sent for " .. duration .. " seconds"); fibaro:sleep(duration); stop(); else fibaro:debug("play sent"); local n = 0; currentTransportState = "TRANSITIONING"; while (currentTransportState == "TRANSITIONING") do if (n > 10) then break end; getTransportState(); fibaro:debug(currentTransportState); fibaro:sleep(5000); n = n + 1; end local i = 0; currentTransportState = "PLAYING"; while (currentTransportState == "PLAYING") do if (i > 10 and PlayUnlimited ~= "Yes") then break end; getTransportState(); fibaro:debug(currentTransportState); fibaro:sleep(2000); i = i + 1; end fibaro:sleep(1000); stop(); end -- update volume with value before tts if different if (ttsVolumeIsDifferent == true) then setVolume(lastVolume); ttsVolumeIsDifferent = false; end end); end sseek = function() return sendSoapMessage( -- control url "/MediaRenderer/AVTransport/Control", -- service type "urn:schemas-upnp-org:service:AVTransport:1", -- action { name = "Seek", service = "urn:schemas-upnp-org:service:AVTransport:1" }, -- soap body data (options) "<InstanceID>0</InstanceID>,<Unit>TRACK_NR</Unit>,<Target>1</Target>", -- callback (options) function(response) fibaro:debug("Seek"); end); end que = function() return sendSoapMessage( -- control url "/MediaRenderer/AVTransport/Control", -- service type "urn:schemas-upnp-org:service:AVTransport:1", -- action { name = "AddURIToQueue", service = "urn:schemas-upnp-org:service:AVTransport:1" }, -- soap body data (options) "<InstanceID>0</InstanceID>,<EnqueuedURI>file:///jffs/settings/savedqueues.rsq#".. list_nbr.."</EnqueuedURI>,<EnqueuedURIMetaData><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="SQ:1" parentID="SQ:" restricted="true"><dc:title>".. list_name .."</dc:title><upnp:class>object.container.playlistContainer</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">RINCON_AssociatedZPUDN</desc></item></DIDL-Lite></EnqueuedURIMetaData>,<DesiredFirstTrackNumberEnqueued>1</DesiredFirstTrackNumberEnqueued>,<EnqueueAsNext>1</EnqueueAsNext>", -- callback (options) function(response) fibaro:debug("que"); end); end setVolume = function(value) return sendSoapMessage( -- control url "/MediaRenderer/RenderingControl/Control", -- service type "urn:schemas-upnp-org:service:RenderingControl:1", -- action { name = "SetVolume", service = "urn:schemas-upnp-org:service:RenderingControl:1" }, -- soap body data (options) "<InstanceID>0</InstanceID><Channel>Master</Channel><DesiredVolume>" .. tostring(value) .. "</DesiredVolume>", -- callback (options) function(response) fibaro:debug("Volume set: " .. value); end); end getVolume = function() fibaro:log("Get volume, please wait..."); return sendSoapMessage( -- control url "/MediaRenderer/RenderingControl/Control", -- service type "urn:schemas-upnp-org:service:AVTransport:1", -- action { name = "GetVolume", service = "urn:schemas-upnp-org:service:RenderingControl:1" }, -- soap body data (options) "<InstanceID>0</InstanceID><Channel>Master</Channel>", -- callback (options) function(response) currentVolume = tonumber(response:match("<CurrentVolume>(.+)</CurrentVolume>") or 0); end); end getTransportState = function() return sendSoapMessage( -- control url "/MediaRenderer/AVTransport/Control", -- service type "urn:schemas-upnp-org:service:AVTransport:1", -- action { name = "GetTransportInfo", service = "urn:schemas-upnp-org:service:AVTransport:1" }, -- soap body data (options) "<InstanceID>0</InstanceID>", -- callback (options) function(response) currentTransportState = response:match("<CurrentTransportState>(.+)</CurrentTransportState>") or ""; end); end playFile= function(volume) return sendSoapMessage( -- control url SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI" "/MediaRenderer/AVTransport/Control", -- service type "urn:schemas-upnp-org:service:AVTransport:1", -- action { name = "SetAVTransportURI", service = "urn:schemas-upnp-org:service:AVTransport:1" }, -- soap body data (options) "<InstanceID>0</InstanceID>,<CurrentURI>x-rincon-queue:"..uid.."#0</CurrentURI>,<CurrentURIMetaData></CurrentURIMetaData>", -- zestawienie playlist -- control url --"/MediaServer/ContentDirectory/Control", -- service type --"urn:schemas-upnp-org:service:ContentDirectory:1", -- action --{ name = "Browse", service = "urn:schemas-upnp-org:service:ContentDirectory:1" }, -- soap body data (options) --"<ObjectID>Q:0</ObjectID>,<BrowseFlag>BrowseDirectChildren</BrowseFlag>,<Filter>dc:title,res,dc:creator,upnp:artist,upnp:album,upnp:albumArtURI</Filter>,<StartingIndex>0</StartingIndex>,<RequestedCount>100</RequestedCount>,<SortCriteria></SortCriteria></u:Browse>", -- callback (options) function(response) -- retrieve current transport state getTransportState(); lastTransportState = currentTransportState; -- unmute before unMute(); -- retrieve volume getVolume(); lastVolume = currentVolume; -- set tts volume if <> with current if (volume ~= nil and volume ~= currentVolume) then setVolume(volume); ttsVolumeIsDifferent = true; end sseek(); play(); end); end -- en paramètres: le fichier, puis le volume... que(); playFile(FileVol);
-
After many test i find that this is problem in LUA interpreter in HC2, when error or information about null data is send in html not classical json data. The Fibaro support confirmed my observation (13.02) and informed that add the patch to one of next system release. (not 4.111 because list of patch for this version is closed) The problem internal ticket number in Fibaro is SFS-340 In this moment I use watchdog for the scene with this problems with delayed restart. Sorry I write answer in English because from phone for me is faster.
-
I have the same problem when I have more that 30 noreading/delated message in status bar of phone. Reboot phone or delete message Wysłane z mojego EVA-L09 przy użyciu Tapatalka
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
Same line all the time I'm in b trip for two week without stable access to my HC2. When it's possible I will write in my next post line (commad) with and without double PuSH. Wysłane z mojego EVA-L09 przy użyciu Tapatalka
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
@pepite , new GEA Scene with old config lines - the same result. Some of GEA.add commands generate double push, not all ex. GEA.add (717, 30*60, "Odłączone media na czas wyjazdu", {{"turnOn",336}}) GEA.add (717, -1, "Podłączono media po wyjazdzie", {{"Inverse"},{"turnOff",336}}) work fine
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
@pepite, 1. no double line (gea.add command), only one entry in the debug for command and push 2. this applies only to the PUSH command - text in ".." , the right command {turn ON, Off etc} is executed once. 3. with not all gea.add command generate double PUSH 4. today I will run a new copy of the GEA and the old will stop... and see You tomorrow ;-)
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
J'ai un problème de quelques jours, je changeai rien dans mon GEA, mais le supportvérifiais pourquoi HC2 se bloque. depuis ce temps, une partie du message PUSH je reçois deux fois (pas toutes) ex.: commande GEA: GEA.add({"Alarm", 536}, 1, "Tryb nocny aktywacja", {{"Global", "czy_dzien", "nie"}}) debug (l'image ajoutée) Le message sur le portable: 21:00 PUSH (HC2-xxxxxx) Tryb nocny aktywacja 20:59 PUSH (HC2-xxxxxx) Tryb nocny aktywacja Je même pour (deux identiques message): GEA.add({"Property!", 819, "state", "Closed"}, 30*60, "Garaż otwarty od #duration# minut, #time#", {{"Repeat"},{"Label", 45, "Message", "Garaż otwarty od #duration# minut"}, {"VirtualDevice", 45,1}}) 18:12 PUSH (HC2-xxxxxx) Garaż otwarty od 1h 30m minut, 18:12:46 18:12 PUSH (HC2-xxxxxx) Garaż otwarty od 1h 30m minut, 18:12:38 Bien sûr, travailler un GEA
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
ça marche! mon problème est "ui.Label1.value" au lieu de "Label1" Avec la version 4.100 marche, et à partir de 4.104 non. Je l'ai testé deux HC 4.100 et 4.104 Merci @pepite pour ton aide
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :