├── DiscrciminaciónHoraria.txt ├── EncenderEnHoraBarata.txt ├── PVPC_EXCEDENTES.txt ├── PrecioPVPC.txt ├── README.md ├── Tarifa 3 Tramos ├── DHA_3T.dz ├── README.md ├── TRAMOS_HORARIOS.dz ├── tarifaLuz.png └── tarifaLuz_2.png ├── camera.html ├── checkBestPVPCPrice.txt └── escenarioContaminacion.txt /DiscrciminaciónHoraria.txt: -------------------------------------------------------------------------------- 1 | --22.04.2020 2 | -- No se actualizaba correctamente el dispositivo texto llamado TARIFA 3 | --19.04.2020 4 | -- Ya no es necesario crear la variable dentro de domoticz llamada powerAnterior. Se creará sola dentro del script 5 | --11.04.2020 6 | --Si la raspberry tiene definida la hora correctamente, hará el cambio veramo invierno de franja horaria 7 | --17.02.2019 -- versión inicial 8 | --Es necesario tener previamente creado el PZEM que es el actual sistema de medida 9 | --Cambiar los domoticz.devices('PZEM') al nombre vuestro que corresponda 10 | --Creamos un nuevo dispositivo P1 Energy, el cual en el ejemplo yo he llamado DHA 11 | --Creamos también un nuevo dispositivo texto llamado TARIFA 12 | --Añadimos el siguiente script DzEvents 13 | --Los comandos PRINT están puestos con fin de Debug, quitarlos si os funciona correctamente 14 | --El ejemplo añade P1 o P2 según hora. En el ejemplo entre 23 y 12h sería valle y el resto punta 15 | --En necesario crear la variable powerAnterior !! 16 | 17 | --https://domotuto.com/registro-de-consumo-en-dha/ 18 | 19 | return { 20 | on = { 21 | timer = { 22 | 'every 1 minutes' -- just an example to trigger the request 23 | } 24 | }, 25 | data = { 26 | horario = { initial = "" }, 27 | counterPrev = { initial = "0" } 28 | }, 29 | execute = function(domoticz, item) 30 | local tipoHorario = domoticz.data.horario 31 | local inicio = 0 32 | local fin = 0 33 | --Obtenemos la lectura actual para compararla con la anterior y según que hora sea cargamos en P1 o P2 34 | instantNow = domoticz.devices('PZEM').usage 35 | --print('Instantaneo W = '..instantNow) 36 | counterToday = domoticz.devices('PZEM').counterToday*1000 37 | counterPrev = domoticz.data.counterPrev 38 | --print('counterToday = '..counterToday) 39 | --print('powerAnterior = '..counterPrev) 40 | domoticz.log('counterToday = '..counterToday, domoticz.LOG_INFO) 41 | domoticz.data.counterPrev = counterToday 42 | --domoticz.variables('powerAnterior').set(counterToday) 43 | 44 | --Calculamos el consumo desde la última lectura 45 | if(tonumber(counterToday)>=tonumber(counterPrev))then 46 | consumo = tonumber(counterToday)-tonumber(counterPrev) 47 | else 48 | consumo = tonumber(counterToday) 49 | end 50 | --print('Consumo último minuto = '..consumo) 51 | 52 | --Ahora cargamos P1 o P2 según el tramo horario 53 | p1 = domoticz.devices('DHA').usage1 54 | p2 = domoticz.devices('DHA').usage2 55 | --domoticz.devices.updateP1(usage1, usage2, return1, return2, cons, prod) 56 | 57 | 58 | 59 | local Time = require('Time') 60 | local now = Time() 61 | 62 | 63 | --de 22 a 12 valle 64 | if((now.hour == 0 and now.minute==1)or tipoHorario == "" ) then 65 | tipoHorario = os.date("%Z") 66 | domoticz.data.horario = tipoHorario 67 | domoticz.log('Actualizado horario a ' .. tipoHorario, domoticz.LOG_ERROR) 68 | end 69 | --domoticz.log('Actualizado horario a ' .. tipoHorario, domoticz.LOG_ERROR) 70 | if(tipoHorario=="CEST")then 71 | --horario verano 72 | inicio = 23 73 | fin = 13 74 | else 75 | --horario invierno 76 | inicio = 22 77 | fin = 12 78 | end 79 | if(now.hour >= inicio or now.hour < fin)then 80 | --print('Valle') 81 | p2 = p2 + consumo 82 | if(domoticz.devices('TARIFA').text~='Valle')then 83 | domoticz.devices('TARIFA').updateText('Valle') 84 | end 85 | domoticz.devices('DHA').updateP1(p1, p2, 0, 0, instantNow, 0) 86 | else 87 | --print('Punta') 88 | p1 = p1 + consumo 89 | if(domoticz.devices('TARIFA').text~='Punta')then 90 | domoticz.devices('TARIFA').updateText('Punta') 91 | end 92 | domoticz.devices('DHA').updateP1(p1, p2, 0, 0, instantNow, 0) 93 | end 94 | --de 12 a 22 punta 95 | end 96 | } 97 | -------------------------------------------------------------------------------- /EncenderEnHoraBarata.txt: -------------------------------------------------------------------------------- 1 | -- Partimos de la base de que ya tenemos funcionando el script que nos dice que hora es la más barata hoy en PVPC 2 | -- https://github.com/ayasystems/domoticzScript/blob/master/checkBestPVPCPrice.txt 3 | -- Este script comprobará si estamos en esa hora y encenderá durante una hora el dispositivo que queramos, 4 | -- en este caso la depuradora de la piscina 5 | -- 6 | 7 | return { 8 | on = { 9 | timer = { 10 | 'at *:00' --comprobamos en todas las horas, al minuto 00 11 | }, 12 | }, 13 | execute = function(domoticz, timer) 14 | --leemos cual es la hora barata almacenada en la variable lowCostEnergyHour por el script 15 | --https://github.com/ayasystems/domoticzScript/blob/master/checkBestPVPCPrice.txt 16 | -- 17 | local horaBarata = domoticz.variables('lowCostEnergyHour').value 18 | 19 | --vemos que hora es ahora mismo 20 | local Time = require('Time') 21 | local now = Time() 22 | --domoticz.log('now.hour: '..now.hour, domoticz.LOG_ERROR) 23 | --domoticz.log('horaBarata: '..horaBarata, domoticz.LOG_ERROR) 24 | 25 | --si la hora es igual a la hora barata... 26 | if((now.hour == tonumber(horaBarata)))then 27 | domoticz.log('Horario feliz encendemos dispositivos', domoticz.LOG_ERROR) 28 | domoticz.devices('Depuradora').switchOn().forMin(60) 29 | end 30 | end 31 | } 32 | -------------------------------------------------------------------------------- /PVPC_EXCEDENTES.txt: -------------------------------------------------------------------------------- 1 | -- Este script baja la lista de precios a la que pagan los excedentes en PVPC 2 | 3 | 4 | -- Para cargar el precio de cada hora tenemos también que crear 24 variables 5 | -- EXCEDENTES_0, EXCEDENTES_1, EXCEDENTES_2 .... así hasta EXCEDENTES_23 6 | -- Crearemos otro dummie, de tipo custom sensor que se llame "PrecioExcedente" 7 | -- Las variables EXCEDENTES_XX serán un variables tipo string / texto 8 | -- Para probarlo podéis crear una escena que se llame testExcedentes, cada vez que se lance esa escena se actualizarán los datos 9 | -- Autor @ea4gkq 10 | -- Visita www.domotuto.com 11 | 12 | return { 13 | on = { 14 | timer = { 15 | 'at 00:01', 16 | 'every hour' 17 | 18 | }, 19 | scenes = { 20 | 'testExcedentes' 21 | }, 22 | httpResponses = { 23 | 'pvpcExcedentesCallback' -- must match with the callback passed to the openURL command 24 | } 25 | }, 26 | execute = function(domoticz, item) 27 | 28 | 29 | if (item.isTimer or item.isScene) then 30 | domoticz.log('Script PVCP Excedentes raised by timer', domoticz.LOG_ERROR) 31 | local Time = require('Time') 32 | local now = Time() 33 | --SUSTITUIR LAS XXXXXX POR TU TOKEN DE ESIOS 34 | local token = 'Token token=\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"'; 35 | --'{"test":[1,2,3,4]}' 36 | 37 | --local headerToken = { ['Authorization'] = ''..token..'' }; 38 | local headerToken = { ['Authorization'] = ''..token..'', ['x-api-key'] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }; 39 | 40 | local precioLuz = domoticz.devices('PrecioExcedente').sensorValue 41 | 42 | if( (now.hour == 0 and now.minutes == 1 )or precioLuz == '999' or item.isScene ) then 43 | --domoticz.log('Entro al for', domoticz.LOG_ERROR) 44 | for i = 1,24,1 45 | do 46 | hora = i-1 47 | local someValue = 999 48 | print('Reset valor PVPC '..tostring(i-1)..'h '..someValue) 49 | local variableName = 'EXCEDENTES_'..hora 50 | domoticz.variables(variableName).set(someValue) 51 | 52 | end 53 | 54 | domoticz.log('Llamada API PVPC', domoticz.LOG_ERROR) 55 | domoticz.openURL({ 56 | url = 'https://api.esios.ree.es/indicators/1739', 57 | method = 'GET', 58 | headers = headerToken, 59 | callback = 'pvpcExcedentesCallback', -- see httpResponses above. 60 | }) 61 | end 62 | 63 | local variableName = 'EXCEDENTES_'..now.hour 64 | --domoticz.log('Variable: '..variableName, domoticz.LOG_ERROR) 65 | local precioActual = domoticz.variables(variableName).value 66 | --domoticz.log('precioActual: '..precioActual, domoticz.LOG_ERROR) 67 | --domoticz.log('Precio actual: '..precioActual, domoticz.LOG_ERROR) 68 | local precioFloat = 0 69 | precioFloat = tonumber(precioActual)+0.0 70 | if(precioFloat<900)then 71 | domoticz.devices('PrecioExcedente').updateCustomSensor(precioFloat) 72 | else 73 | domoticz.devices('PrecioExcedente').updateCustomSensor(0) 74 | 75 | end 76 | 77 | end 78 | 79 | if (item.isHTTPResponse) then 80 | print('Respuesta API PVPC Excedentes'..item.statusCode) 81 | if (item.statusCode == 200) then 82 | --print("Es Json: "..tostring(item.isJSON)) 83 | if (item.isJSON) then 84 | --print("entra 1") 85 | 86 | 87 | for i = 1,24,1 88 | do 89 | hora = i-1 90 | --payload.indicator.values 91 | local someValue = item.json.indicator.values[i]["value"] -- just an example 92 | --someValue = someValue:gsub(',','.') 93 | someValue = tonumber(someValue)/10 94 | --print('Valor excedente '..tostring(someValue)..'h '..someValue) 95 | 96 | local variableName = 'EXCEDENTES_'..hora 97 | domoticz.variables(variableName).set(someValue) 98 | 99 | 100 | 101 | end 102 | 103 | 104 | end 105 | else 106 | domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR) 107 | domoticz.log(item, domoticz.LOG_ERROR) 108 | end 109 | 110 | end 111 | 112 | 113 | end 114 | } 115 | -------------------------------------------------------------------------------- /PrecioPVPC.txt: -------------------------------------------------------------------------------- 1 | -- Este script baja la lista de precios de tarifa PVPC 2.0 TD con discrminación horaria y guarda en una 2 | -- variable (lowCostEnergyHour) la hora a la que la energía tiene el mejor precio al cabo del día 3 | -- Es necesario tener creada la variable lowCostEnergyHour como tipo string 4 | -- Para cargar el precio de cada hora tenemos también que crear 24 variables 5 | -- PVPC_0, PVPC_1, PVPC_2 .... así hasta PVPC_23 6 | -- Crearemos otro dummie, de tipo texto, que se llame "Precio Luz" que cada hora se actualizará con el precio en ese momento de la Luz 7 | -- Crearemos otro dummie, de tipo custom sensor que se llame "PrecioPVPC" 8 | -- Tanto los PVPC_XX como el "lowCostEnergyHour" serán un variables tipo texto 9 | -- Autor @ea4gkq 10 | -- Visita www.domotuto.com 11 | 12 | 13 | 14 | return { 15 | on = { 16 | timer = { 17 | 'at 00:00', 18 | 'every hour' 19 | 20 | }, 21 | httpResponses = { 22 | 'pvpcCallback' -- must match with the callback passed to the openURL command 23 | } 24 | }, 25 | execute = function(domoticz, item) 26 | 27 | if (item.isTimer) then 28 | domoticz.log('Script PVCP raised by timer', domoticz.LOG_ERROR) 29 | local Time = require('Time') 30 | local now = Time() 31 | 32 | local precioLuz = domoticz.devices('Precio Luz').text 33 | 34 | if(now.hour == 0 or precioLuz == '999' ) then 35 | 36 | for i = 1,24,1 37 | do 38 | hora = i-1 39 | local someValue = 999 40 | print('Reset valor PVPC '..tostring(i-1)..'h '..someValue) 41 | local variableName = 'PVPC_'..hora 42 | domoticz.variables(variableName).set(someValue) 43 | 44 | end 45 | 46 | domoticz.log('Llamada API PVPC', domoticz.LOG_ERROR) 47 | domoticz.openURL({ 48 | url = 'https://api.esios.ree.es/archives/70/download_json?locale=es', 49 | method = 'GET', 50 | callback = 'pvpcCallback', -- see httpResponses above. 51 | }) 52 | end 53 | 54 | local variableName = 'PVPC_'..now.hour 55 | --domoticz.log('Variable: '..variableName, domoticz.LOG_ERROR) 56 | local precioActual = domoticz.variables(variableName).value 57 | --domoticz.log('precioActual: '..precioActual, domoticz.LOG_ERROR) 58 | --domoticz.log('Precio actual: '..precioActual, domoticz.LOG_ERROR) 59 | local precioFloat = 0 60 | precioFloat = tonumber(precioActual)+0.0 61 | if(precioFloat<900)then 62 | domoticz.devices('PrecioPVPC').updateCustomSensor(precioFloat) 63 | else 64 | domoticz.devices('PrecioPVPC').updateCustomSensor(0) 65 | 66 | end 67 | precioActual = tostring(precioActual) 68 | --domoticz.log('Precio actual: '..precioActual, domoticz.LOG_ERROR) 69 | domoticz.devices('Precio Luz').updateText(precioActual) 70 | end 71 | 72 | if (item.isHTTPResponse) then 73 | print('Respuesta API PVPC '..item.statusCode) 74 | if (item.statusCode == 200) then 75 | --print("Es Json: "..tostring(item.isJSON)) 76 | if (item.isJSON) then 77 | --print("entra 1") 78 | local precioEco = 999999 79 | local horaEco = 0 80 | local hora = 0 81 | 82 | for i = 1,24,1 83 | do 84 | hora = i-1 85 | local someValue = item.json.PVPC[i]["PCB"] -- just an example 86 | someValue = someValue:gsub(',','.') 87 | someValue = tonumber(someValue)/10 88 | print('Valor PVPC '..tostring(i-1)..'h '..someValue) 89 | if someValue=tonumber(counterPrev))then 68 | consumo = tonumber(counterToday)-tonumber(counterPrev) 69 | else 70 | consumo = 0 71 | end 72 | 73 | domoticz.data.counterPrev = tonumber(counterToday) 74 | 75 | --domoticz.log('counterToday = '..counterToday, domoticz.LOG_ERROR) 76 | --domoticz.log('counterPrev = '..counterPrev, domoticz.LOG_ERROR) 77 | --domoticz.log('counterDif = '..consumo, domoticz.LOG_ERROR) 78 | --domoticz.log('pValle.counterToday = '..valleToday, domoticz.LOG_ERROR) 79 | --domoticz.log('pLlano.counterToday = '..llanoToday, domoticz.LOG_ERROR) 80 | --domoticz.log('pPunta.counterToday = '..puntaToday, domoticz.LOG_ERROR) 81 | 82 | local coste = ( consumo * ckwh / 1000 ) + .0 --Queremos el coste en céntimos de Euro 83 | 84 | 85 | domoticz.log('Coste = '..coste, domoticz.LOG_ERROR) 86 | 87 | if (1==1)then 88 | if consumo > 0 then 89 | if tarifaActual.level == 0 then --valle 90 | 91 | calc = pLlano.counterToday 92 | pLlano.updateElectricity(0,llanoToday) 93 | 94 | calc = pPunta.counterToday 95 | pPunta.updateElectricity(0,puntaToday) 96 | 97 | 98 | consumo = domoticz.round(consumo + ( valleToday),0) 99 | pValle.updateElectricity(instantNow,tonumber(consumo)) 100 | 101 | if(ckwh<900)then 102 | cValle.incrementCounter(coste) 103 | cLlano.incrementCounter(0) 104 | cPunta.incrementCounter(0) 105 | end 106 | elseif tarifaActual.level == 10 then --llano 107 | 108 | 109 | calc = pValle.counterToday 110 | pValle.updateElectricity(0,valleToday) 111 | 112 | calc = pPunta.counterToday 113 | pPunta.updateElectricity(0,puntaToday) 114 | 115 | consumo = domoticz.round(consumo + ( llanoToday),0) 116 | pLlano.updateElectricity(instantNow,tonumber(consumo)) 117 | 118 | if(ckwh<900)then 119 | cValle.incrementCounter(0) 120 | cLlano.incrementCounter(coste) 121 | cPunta.incrementCounter(0) 122 | end 123 | 124 | elseif tarifaActual.level == 20 then --punta 125 | 126 | calc = pValle.counterToday 127 | pValle.updateElectricity(0,valleToday) 128 | 129 | calc = pLlano.counterToday 130 | pLlano.updateElectricity(0,llanoToday) 131 | 132 | consumo = domoticz.round(consumo + ( puntaToday),0) 133 | pPunta.updateElectricity(instantNow,tonumber(consumo)) 134 | 135 | if(ckwh<900)then 136 | cValle.incrementCounter(0) 137 | cLlano.incrementCounter(0) 138 | cPunta.incrementCounter(coste) 139 | end 140 | 141 | end 142 | domoticz.log('Contador consumo = '..consumo, domoticz.LOG_ERROR) 143 | if(ckwh<900)then 144 | cTotal.incrementCounter(coste) 145 | end 146 | end 147 | else 148 | domoticz.log('Contador consumo = '..consumo, domoticz.LOG_ERROR) 149 | consumo = 0 150 | pValle.updateElectricity(instantNow,consumo) 151 | pLlano.updateElectricity(instantNow,consumo) 152 | pPunta.updateElectricity(instantNow,consumo) 153 | end 154 | 155 | 156 | 157 | end 158 | } 159 | -------------------------------------------------------------------------------- /Tarifa 3 Tramos/README.md: -------------------------------------------------------------------------------- 1 | # Discriminación horaria 3 tramos 🚀 2 | 3 | 4 | Con estos scripts tendremos 3 contadores de la luz y acumularemos el coste en céntimos de euro en cada una de las nuevas tarifas 2.0 TD 5 | 6 | ![Web](https://github.com/ayasystems/domoticzScript/blob/master/Tarifa%203%20Tramos/tarifaLuz_2.png) 7 | 8 | 9 | Vamos al lio...... 10 | 11 | 1. Necesitamos crear un **selector switch** llamado TarifaLuz: 12 | 13 | - Level 0 -> Valle 14 | - Level 10 -> Llano 15 | - Level 20 -> Punta 16 | 17 | 18 | ![Web](https://github.com/ayasystems/domoticzScript/blob/master/Tarifa%203%20Tramos/tarifaLuz.png) 19 | 20 | 21 | 2. Creamos 3 **dummies virtuales** de tipo **Electric (Instant+Counter) computo de energía desde dispositivo** 22 | 23 | - PPunta 24 | - PLlano 25 | - PValle 26 | 27 | 2. Creamos 4 **dummies virtuales** de tipo **Counter incremental**, los editamos y ponemos **type: counter y value units: cent€** 28 | 29 | - CPunta 30 | - CLlano 31 | - CValle 32 | - CTotal 33 | 34 | 4. Solo nos queda crear dos nuevo eventos en DZEvents. 35 | - DHA_3T 36 | 37 | **Especial atención al device PZEM, cambiar según corresponda, debe ser el que mide el consumo de la casa** 38 | 39 | - TRAMOS_HORARIOS 40 | 41 | **Este script necesita tener funcionando y actualizado el script de precios de PVPC** https://github.com/ayasystems/domoticzScript/blob/master/PrecioPVPC.txt 42 | 43 | Puedes acceder a más scripts y tutoriales en https://domotuto.com/ 44 | 45 | 46 | ## Expresiones de Gratitud 🎁 47 | * Dale una estrella al proyecto 48 | * Comenta a otros sobre este proyecto 📢 49 | * Invita una cerveza 🍺 o un café ☕ a alguien del equipo. 50 | * Da las gracias públicamente 🤓. 51 | -------------------------------------------------------------------------------- /Tarifa 3 Tramos/TRAMOS_HORARIOS.dz: -------------------------------------------------------------------------------- 1 | return { 2 | on = { 3 | timer = {"every hour" 4 | -- ,"every minutes" --solo para pruebas 5 | } 6 | }, 7 | data = { 8 | tramoHorario = { initial = "" } 9 | }, 10 | logging = { 11 | level = domoticz.LOG_ERROR, 12 | marker = 'TRAMOS_HORARIOS', 13 | }, 14 | execute = function(domoticz, triggeredItem) 15 | --Necesario tener creado un selector switch con estos niveles, llamado TarifaLuz 16 | --Level name 17 | --0 Valle 18 | --10 Llano 19 | --20 Punta 20 | 21 | local Time = require('Time') 22 | local now = Time() 23 | local tipoHorario = os.date("%Z") 24 | local diaSemana = 0 25 | 26 | -- domoticz.log('now.wday = '..now.wday, domoticz.LOG_ERROR) 27 | 28 | if now.wday == 1 then 29 | diaSemana = 7 30 | else 31 | diaSemana = now.wday - 1 --ajustar según sistema operativo 32 | end 33 | 34 | 35 | 36 | local tValle = 'VALLE' 37 | local tLlano = 'LLANO' 38 | local tPunta = 'PUNTA' 39 | 40 | local tramoActual = "" 41 | 42 | local swTarifa = domoticz.devices('TarifaLuz') --Selecto switch TarifaLuz 43 | 44 | --Para verificar que recuperamos bien el día de la semana activar la siguente línea de debug y verificar que corresponda a 45 | -- 1 Lunes 46 | -- 2 Martes 47 | -- 3 Miércoles 48 | -- ... 49 | -- 7 Domingo 50 | 51 | --domoticz.log('Día semana = '..diaSemana, domoticz.LOG_ERROR) 52 | -- now.wday 53 | if (diaSemana == 6 or diaSemana == 7) then --los festivos no se controlarán 54 | 55 | tramoActual = tValle 56 | else 57 | 58 | --0 a 8 Valle 59 | --8 a 10 Llano 60 | --10 a 14 Punta 61 | --14 a 18 Llano 62 | --18 a 22 Punta 63 | --22 a 24 Llano 64 | if ( now.hour>=0 and now.hour<8 ) then 65 | tramoActual = tValle 66 | elseif ( now.hour>=8 and now.hour<10) then 67 | tramoActual = tLlano 68 | elseif ( now.hour>=10 and now.hour<14) then 69 | tramoActual = tPunta 70 | elseif ( now.hour>=14 and now.hour<18) then 71 | tramoActual = tLlano 72 | elseif ( now.hour>=18 and now.hour<22) then 73 | tramoActual = tPunta 74 | elseif ( now.hour>=22 ) then 75 | tramoActual = tLlano 76 | end 77 | 78 | 79 | 80 | end 81 | 82 | if tramoActual == tValle then 83 | swTarifa.setLevel(0) 84 | elseif tramoActual == tLlano then 85 | swTarifa.setLevel(10) 86 | elseif tramoActual == tPunta then 87 | swTarifa.setLevel(20) 88 | end 89 | 90 | end 91 | } 92 | -------------------------------------------------------------------------------- /Tarifa 3 Tramos/tarifaLuz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayasystems/domoticzScript/9bec17af3e6ef48ebed33d4d3a0b8eeb714c129d/Tarifa 3 Tramos/tarifaLuz.png -------------------------------------------------------------------------------- /Tarifa 3 Tramos/tarifaLuz_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayasystems/domoticzScript/9bec17af3e6ef48ebed33d4d3a0b8eeb714c129d/Tarifa 3 Tramos/tarifaLuz_2.png -------------------------------------------------------------------------------- /camera.html: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Visor cámaras @ea4gkq 21 | 41 | 42 | 43 | 44 |
45 |
46 | 47 | 48 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /checkBestPVPCPrice.txt: -------------------------------------------------------------------------------- 1 | -- Este script baja la lista de precios de tarifa PVPC con discrminación horaria y guarda en una 2 | -- variable (lowCostEnergyHour) la hora a la que la energía tiene el mejor precio al cabo del día 3 | -- Es necesario tener creada la variable lowCostEnergyHour como tipo string 4 | -- Script generado para DzEvents 5 | return { 6 | on = { 7 | timer = { 8 | 'at 00:00' 9 | }, 10 | httpResponses = { 11 | 'pvpcCallback' -- must match with the callback passed to the openURL command 12 | } 13 | }, 14 | execute = function(domoticz, item) 15 | 16 | if (item.isTimer) then 17 | print('Llamada API PVPC') 18 | domoticz.openURL({ 19 | url = 'https://api.esios.ree.es/archives/70/download_json?locale=es', 20 | method = 'GET', 21 | callback = 'pvpcCallback', -- see httpResponses above. 22 | }) 23 | end 24 | 25 | if (item.isHTTPResponse) then 26 | print('Respuesta API PVPC '..item.statusCode) 27 | if (item.statusCode == 200) then 28 | if (item.isJSON) then 29 | 30 | local precioEco = 999999 31 | local horaEco = 0 32 | 33 | for i = 1,24,1 34 | do 35 | 36 | local someValue = item.json.PVPC[i]["NOC"] -- just an example 37 | someValue = someValue:gsub(',','.') 38 | someValue = tonumber(someValue)/1000 39 | print('Valor PVPC '..tostring(i-1)..'h '..someValue) 40 | if someValue