02.09.2020, 17:24
(15.05.2020, 12:45)esteve.budia Wrote: Original script was designed by me....Hi Esteve
I did it for share of course
-- =======================================================================================
-- =======================================================================================
-- =======================================================================================
-- =======================================================================================
-- ==== ejemplo 20.3 Término de facturación de energía activa del PVPC =========
-- =======================================================================================
-- =======================================================================================
-- =======================================================================================
-- ===============================SCHNEIDER=ELECTRIC=esteve=budia=2018====================
There is one thing that I do not understand about your script, it is assumed that what is downloaded from ESIOS is a json, so it should be converted to a lua table with json.decode (value), where value would be response_body, but you have it from another shape.
In the log that is obtained, put:
Code:
Event for OFF TOTAL (0/0/1) 02.09.2020 19:22:10
* arg: 1
* number: 200
* arg: 2
* table:
[1]
* string: {"indicator":{"name":"Término de facturación de energía activa del PVPC peaje por defecto suma componentes","short_name":"PVPC T. Defecto","id":10229,"composited":true,"step_type":"linear","disaggregated":false,"magnitud":[{"name":"Precio","id":23}],"tiempo":[{"name":"Hora","id":4}],"geos":[{"geo_id":3,"geo_name":"España"}],"values_updated_at":"2020-09-01T20:25:03.000+02:00","values":[{"value":102.04,"datetime":"2020-09-02T00:00:00.000+02:00","datetime_utc":"2020-09-01T22:00:00Z","tz_time":"2020-09-01T22:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":98.29,"datetime":"2020-09-02T01:00:00.000+02:00","datetime_utc":"2020-09-01T23:00:00Z","tz_time":"2020-09-01T23:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":96.52,"datetime":"2020-09-02T02:00:00.000+02:00","datetime_utc":"2020-09-02T00:00:00Z","tz_time":"2020-09-02T00:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":95.27,"datetime":"2020-09-02T03:00:00.000+02:00","datetime_utc":"2020-09-02T01:00:00Z","tz_time":"2020-09-02T01:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":96.4,"datetime":"2020-09-02T04:00:00.000+02:00","datetime_utc":"2020-09-02T02:00:00Z","tz_time":"2020-09-02T02:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":99.22,"datetime":"2020-09-02T05:00:00.000+02:00","datetime_utc":"2020-09-02T03:00:00Z","tz_time":"2020-09-02T03:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":104.97,"datetime":"2020-09-02T06:00:00.000+02:00","datetime_utc":"2020-09-02T04:00:00Z","tz_time":"2020-09-02T04:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":104.29,"datetime":"2020-09-02T07:00:00.000+02:00","datetime_utc":"2020-09-02T05:00:00Z","tz_time":"2020-09-02T05:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":104.63,"datetime":"2020-09-02T08:00:00.000+02:00","datetime_utc":"2020-09-02T06:00:00Z","tz_time":"2020-09-02T06:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":104.91,"datetime":"2020-09-02T09:00:00.000+02:00","datetime_utc":"2020-09-02T07:00:00Z","tz_time":"2020-09-02T07:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":102.06,"datetime":"2020-09-02T10:00:00.000+02:00","datetime_utc":"2020-09-02T08:00:00Z","tz_time":"2020-09-02T08:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":102.28,"datetime":"2020-09-02T11:00:00.000+02:00","datetime_utc":"2020-09-02T09:00:00Z","tz_time":"2020-09-02T09:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":103.16,"datetime":"2020-09-02T12:00:00.000+02:00","datetime_utc":"2020-09-02T10:00:00Z","tz_time":"2020-09-02T10:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":101.96,"datetime":"2020-09-02T13:00:00.000+02:00","datetime_utc":"2020-09-02T11:00:00Z","tz_time":"2020-09-02T11:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":102.02,"datetime":"2020-09-02T14:00:00.000+02:00","datetime_utc":"2020-09-02T12:00:00Z","tz_time":"2020-09-02T12:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":102.52,"datetime":"2020-09-02T15:00:00.000+02:00","datetime_utc":"2020-09-02T13:00:00Z","tz_time":"2020-09-02T13:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":105.05,"datetime":"2020-09-02T16:00:00.000+02:00","datetime_utc":"2020-09-02T14:00:00Z","tz_time":"2020-09-02T14:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":106.52,"datetime":"2020-09-02T17:00:00.000+02:00","datetime_utc":"2020-09-02T15:00:00Z","tz_time":"2020-09-02T15:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":106.65,"datetime":"2020-09-02T18:00:00.000+02:00","datetime_utc":"2020-09-02T16:00:00Z","tz_time":"2020-09-02T16:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":108.91,"datetime":"2020-09-02T19:00:00.000+02:00","datetime_utc":"2020-09-02T17:00:00Z","tz_time":"2020-09-02T17:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":110.41,"datetime":"2020-09-02T20:00:00.000+02:00","datetime_utc":"2020-09-02T18:00:00Z","tz_time":"2020-09-02T18:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":111.91,"datetime":"2020-09-02T21:00:00.000+02:00","datetime_utc":"2020-09-02T19:00:00Z","tz_time":"2020-09-02T19:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":109.16,"datetime":"2020-09-02T22:00:00.000+02:00","datetime_utc":"2020-09-02T20:00:00Z","tz_time":"2020-09-02T20:00:00.000Z","geo_id":3,"geo_name":"España"},{"value":104.25,"datetime":"2020-09-02T23:00:00.000+02:00","datetime_utc":"2020-09-02T21:00:00Z","tz_time":"2020-09-02T21:00:00.000Z","geo_id":3,"geo_name":"España"}]}}
It is supposed to be a table, but it only has one field [1] and what it contains is a string with all the result? How do I keep for example the short name of PVPC to assign it, for example to a virtual object? Or prices, which is the important thing of course.
Should it be string manipulation functions? Some example?
Thank you