Gå til innhold
  • Bli medlem
Støtt hjemmeautomasjon.no!

Anbefalte innlegg

Skrevet

Har fått ut data fra mitt renovasjonsselskap og ønsker å bygge en sensor i HA for å få varsling. Før hadde jeg en som gikk på 4/2 uker, men nå har de begynt med endrede dager og da trenger jeg litt berdre logikk og kommunen/selskapet er ikke med på min renovasjon så den får jeg ikke brukt.

 

Ser det er en rest sensor som kan brukes, men usikker på hvordan jeg fanger alle datoer som et parameter pr. type noen som kan veilede litt?

Altså, jeg ønsker følgende oppsett på sensorer:

 

sensor.restavfall

  hetedatoer: 2021-12-17, 2021-04-17, .. .. ..

sensor.matavfall

  hentedatoer: .. ... 

sensor.plast

  hentedatoer: .. ..

...

....

..

Noen som kan veilede meg? 

JSON fila ser slik ut:

 

[
    {
        "name""Restavfall",
        "date""2021-12-17",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-04-20",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-05-04",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-05-20",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-06-04",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-06-18",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-07-02",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-07-16",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-04-06",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-07-30",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-08-27",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-09-10",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-09-24",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-10-08",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-10-22",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-11-05",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-11-19",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-08-13",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Restavfall",
        "date""2021-12-03",
        "fractionId"9999,
        "fractionGuid""b4bbf08d-30f0-4024-9f53-e42229ec48a6",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-04-06",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-06-04",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-11-19",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-12-03",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-10-08",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-09-24",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-09-10",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-08-27",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-08-13",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-07-30",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-07-16",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-07-02",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-06-18",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-11-05",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-10-22",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-12-17",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-05-04",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-04-20",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Matavfall",
        "date""2021-05-20",
        "fractionId"2110,
        "fractionGuid""ccdd09f5-3510-43bb-9bb4-2b192230d354",
        "route"30403,
        "routeName""0304",
        "frequency"2,
        "startDay"4
    },
    {
        "name""Papir, papp og kartong",
        "date""2021-12-17",
        "fractionId"2400,
        "fractionGuid""8998844f-406e-458c-b8da-8e8249f5c321",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Papir, papp og kartong",
        "date""2021-11-19",
        "fractionId"2400,
        "fractionGuid""8998844f-406e-458c-b8da-8e8249f5c321",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Papir, papp og kartong",
        "date""2021-10-22",
        "fractionId"2400,
        "fractionGuid""8998844f-406e-458c-b8da-8e8249f5c321",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Papir, papp og kartong",
        "date""2021-09-24",
        "fractionId"2400,
        "fractionGuid""8998844f-406e-458c-b8da-8e8249f5c321",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Papir, papp og kartong",
        "date""2021-04-06",
        "fractionId"2400,
        "fractionGuid""8998844f-406e-458c-b8da-8e8249f5c321",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Papir, papp og kartong",
        "date""2021-08-27",
        "fractionId"2400,
        "fractionGuid""8998844f-406e-458c-b8da-8e8249f5c321",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Papir, papp og kartong",
        "date""2021-07-30",
        "fractionId"2400,
        "fractionGuid""8998844f-406e-458c-b8da-8e8249f5c321",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Papir, papp og kartong",
        "date""2021-07-02",
        "fractionId"2400,
        "fractionGuid""8998844f-406e-458c-b8da-8e8249f5c321",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Papir, papp og kartong",
        "date""2021-06-04",
        "fractionId"2400,
        "fractionGuid""8998844f-406e-458c-b8da-8e8249f5c321",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Papir, papp og kartong",
        "date""2021-05-04",
        "fractionId"2400,
        "fractionGuid""8998844f-406e-458c-b8da-8e8249f5c321",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Glass- og metallemballasje",
        "date""2021-07-30",
        "fractionId"2612,
        "fractionGuid""2627574c-db98-4d6b-94fd-dfb47a64007d",
        "route"161408,
        "routeName""1614",
        "frequency"8,
        "startDay"4
    },
    {
        "name""Glass- og metallemballasje",
        "date""2021-11-19",
        "fractionId"2612,
        "fractionGuid""2627574c-db98-4d6b-94fd-dfb47a64007d",
        "route"161408,
        "routeName""1614",
        "frequency"8,
        "startDay"4
    },
    {
        "name""Glass- og metallemballasje",
        "date""2021-09-24",
        "fractionId"2612,
        "fractionGuid""2627574c-db98-4d6b-94fd-dfb47a64007d",
        "route"161408,
        "routeName""1614",
        "frequency"8,
        "startDay"4
    },
    {
        "name""Glass- og metallemballasje",
        "date""2021-06-04",
        "fractionId"2612,
        "fractionGuid""2627574c-db98-4d6b-94fd-dfb47a64007d",
        "route"161408,
        "routeName""1614",
        "frequency"8,
        "startDay"4
    },
    {
        "name""Glass- og metallemballasje",
        "date""2021-04-06",
        "fractionId"2612,
        "fractionGuid""2627574c-db98-4d6b-94fd-dfb47a64007d",
        "route"161408,
        "routeName""1614",
        "frequency"8,
        "startDay"4
    },
    {
        "name""Plast",
        "date""2021-11-19",
        "fractionId"3200,
        "fractionGuid""03fc89dd-accb-4b4f-a6b0-667438975720",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Plast",
        "date""2021-09-24",
        "fractionId"3200,
        "fractionGuid""03fc89dd-accb-4b4f-a6b0-667438975720",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Plast",
        "date""2021-08-27",
        "fractionId"3200,
        "fractionGuid""03fc89dd-accb-4b4f-a6b0-667438975720",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Plast",
        "date""2021-07-30",
        "fractionId"3200,
        "fractionGuid""03fc89dd-accb-4b4f-a6b0-667438975720",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Plast",
        "date""2021-07-02",
        "fractionId"3200,
        "fractionGuid""03fc89dd-accb-4b4f-a6b0-667438975720",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Plast",
        "date""2021-06-04",
        "fractionId"3200,
        "fractionGuid""03fc89dd-accb-4b4f-a6b0-667438975720",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Plast",
        "date""2021-05-04",
        "fractionId"3200,
        "fractionGuid""03fc89dd-accb-4b4f-a6b0-667438975720",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Plast",
        "date""2021-04-06",
        "fractionId"3200,
        "fractionGuid""03fc89dd-accb-4b4f-a6b0-667438975720",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Plast",
        "date""2021-12-17",
        "fractionId"3200,
        "fractionGuid""03fc89dd-accb-4b4f-a6b0-667438975720",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    },
    {
        "name""Plast",
        "date""2021-10-22",
        "fractionId"3200,
        "fractionGuid""03fc89dd-accb-4b4f-a6b0-667438975720",
        "route"100402,
        "routeName""1004",
        "frequency"4,
        "startDay"4
    }
]
Skrevet
1 time siden, feddiriko skrev:

Kanskje du kan bruke https://github.com/eyesoft/home-assistant-custom-components ? Jeg bruker den pr. i dag og det fungerer smertefritt. 

 

Det som er trist med custom-components er at de som regel ikke blir vedlikeholdt, og vil plutselig ikke fungere ved en oppdatering av HA.

 

 

Skrevet

Som jeg skriver i innlegget er ikke kommunen med på min renovasjon løsningen.

Fikk til litt logikk i går med å dumpe datoer pr. type til en streng, så nå må jeg finne logikken for å få sortert datoene og funnet ut hvordan jeg får første dato og sette den til en entity. Langsomt arbeid for en som ikke er stødig på kode...

Sent fra min SM-G975F via Tapatalk

Skrevet
På 7.4.2021 den 6.43, monsivar skrev:

Som jeg skriver i innlegget er ikke kommunen med på min renovasjon løsningen.

Fikk til litt logikk i går med å dumpe datoer pr. type til en streng, så nå må jeg finne logikken for å få sortert datoene og funnet ut hvordan jeg får første dato og sette den til en entity. Langsomt arbeid for en som ikke er stødig på kode...

Sent fra min SM-G975F via Tapatalk
 

 

Om du bruker node-red, så har jeg en løsning som kan fungere.. 🙂

 

På 6.4.2021 den 21.43, feddiriko skrev:

Kanskje du kan bruke https://github.com/eyesoft/home-assistant-custom-components ? Jeg bruker den pr. i dag og det fungerer smertefritt. 

 

Du må IKKE oppgradere til siste versjon av HA... Da funker ikke den lengre... 

Skrevet
1 time siden, slippern skrev:

 

Om du bruker node-red, så har jeg en løsning som kan fungere.. 🙂

 

 

Ja, jeg bruker Node Red, men sliter litt med kodeferighetene, har klart å komme meg dit at jeg får ut alle datoer pr avfallstype, enten som en streng eller løpende rapportering av verdier, men har ikke klart å lese meg frem til hvordan jeg skal få sortert det ut til første dato og sette det på en input_datetime for bruk videre.

 

Setter stor pris på om du har noe som kan hjelpe

Skrevet (endret)
2 timer siden, monsivar skrev:

Ja, jeg bruker Node Red, men sliter litt med kodeferighetene, har klart å komme meg dit at jeg får ut alle datoer pr avfallstype, enten som en streng eller løpende rapportering av verdier, men har ikke klart å lese meg frem til hvordan jeg skal få sortert det ut til første dato og sette det på en input_datetime for bruk videre.

 

Setter stor pris på om du har noe som kan hjelpe

aha, det du kan gjøre da er og lage en input_datetime etter hver fractionId, en fractionId tilsvarer en søppelboks... 

Her på berget har vi søppelposer med ulik farge, isteden for 4-5 forskjellige søppelbokser, så jeg trenger bare en dato..

 

Her er min flow, tror den skal fungere til mitt bruk nå.. 

[{"id":"19a61e2a.75f152","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"7268b8b9.eb7ae","type":"inject","z":"19a61e2a.75f152","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 12 * * *","once":false,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":130,"y":120,"wires":[["72257540.a12fbc"]]},{"id":"c70310c4.a7eb78","type":"http request","z":"19a61e2a.75f152","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://komteksky.norkart.no/komtek.renovasjonwebapi/api/tommekalender/?gatenavn=GATENAVN&gatekode=GATEKODE&husnr=HUSNR","tls":"","persist":false,"proxy":"","authType":"","x":150,"y":280,"wires":[["6ddd6b7b.e15cf4"]]},{"id":"72257540.a12fbc","type":"change","z":"19a61e2a.75f152","name":"","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\"Kommunenr\":\"KOMMUENR\",\"RenovasjonAppKey\":\"APPKEY\",\"OS\":\"Android\",\"Connection\":\"Keep-Alive\",\"Accept-Encoding\":\"gzip\",\"User-Agent\":\"okhttp/3.2.0\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":220,"wires":[["c70310c4.a7eb78"]]},{"id":"3f136545.bf33ca","type":"api-call-service","z":"19a61e2a.75f152","name":"","server":"ed1ce5cc.927bb8","version":1,"debugenabled":true,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.matavfall","data":"{\"datetime\": tommedato }","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":180,"y":400,"wires":[[]]},{"id":"6ddd6b7b.e15cf4","type":"change","z":"19a61e2a.75f152","name":"","rules":[{"t":"set","p":"tommedato","pt":"msg","to":"payload[0].Tommedatoer[0]","tot":"msg"},{"t":"set","p":"tommedato2","pt":"msg","to":"payload[0].Tommedatoer[1]","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":160,"y":340,"wires":[["3f136545.bf33ca"]]},{"id":"933ca3bc.8010f8","type":"comment","z":"19a61e2a.75f152","name":"Henter data fra min_renovasjon","info":"","x":170,"y":60,"wires":[]},{"id":"456b8e1f.d725d8","type":"inject","z":"19a61e2a.75f152","name":"Man - Fre 07:30","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"30 07 * * 1,2,3,4,5","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":470,"y":140,"wires":[["736a1536.f05b44"]]},{"id":"736a1536.f05b44","type":"api-current-state","z":"19a61e2a.75f152","name":"","server":"ed1ce5cc.927bb8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_datetime.matavfall","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":510,"y":240,"wires":[["f08da0ae.8c6bd","5f7a2b73.ee12ec"]]},{"id":"3955f9d6.8f2f26","type":"switch","z":"19a61e2a.75f152","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"idag","vt":"str"},{"t":"eq","v":"imorgen","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":430,"y":440,"wires":[["8aac29ce.304d1"],["45aa2ee.529a2d"]]},{"id":"319b0046.3d0ff","type":"function","z":"19a61e2a.75f152","name":"Utregning","func":"var PickupDate = new Date (flow.get(\"PickupDate\"));\nvar date = new Date();\nvar Tomming;\nvar DiffTime\nvar DiffDays\n\n//Regner ut differansen, og gjør det om til antall dager.\nDiffTime = date.getTime() - PickupDate.getTime();\nDiffDays = DiffTime / (1000 * 3600 * 24);\n\n//Gjør datoene om til formatet år/mnd/dag 00:00\ndate = (date.getFullYear() + '-' + ('00' + (date.getMonth()+1)).slice(-2) + '-' + ('00' + date.getDate()).slice(-2) + ' ' + ('00') + ':' + ('00') + ':' + ('00'));\nPickupDate = (PickupDate.getFullYear() + '-' + ('00' + (PickupDate.getMonth()+1)).slice(-2) + '-' + ('00' + PickupDate.getDate()).slice(-2) + ' ' + ('00') + ':' + ('00') + ':' + ('00'));\n\n\nif (PickupDate == date) {\n    Tomming = \"idag\";\n}\nelse if ((DiffDays > 1) && (DiffDays < 2)) {\n    Tomming = \"imorgen\";\n}\nelse Tomming = false;\n\nmsg.payload = Tomming\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":360,"wires":[["3955f9d6.8f2f26"]]},{"id":"c5522a8d.1bf24","type":"inject","z":"19a61e2a.75f152","name":"Man - Fre 22:30","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"30 22 * * 1,2,3,4,5","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":470,"y":180,"wires":[["736a1536.f05b44"]]},{"id":"f08da0ae.8c6bd","type":"function","z":"19a61e2a.75f152","name":"Setter hentedato","func":"flow.set(\"PickupDate\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":790,"y":240,"wires":[[]]},{"id":"8aac29ce.304d1","type":"api-call-service","z":"19a61e2a.75f152","name":"Søppeltømming idag","server":"ed1ce5cc.927bb8","version":1,"debugenabled":false,"service_domain":"notify","service":"","entityId":"","data":"{\"message\":\"Det er søppeltømming idag\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":680,"y":400,"wires":[[]]},{"id":"45aa2ee.529a2d","type":"api-call-service","z":"19a61e2a.75f152","name":"Søppeltømming imorgen","server":"ed1ce5cc.927bb8","version":1,"debugenabled":false,"service_domain":"notify","service":"","entityId":"","data":"{\"message\":\"Det er søppeltømming imorgen\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":690,"y":480,"wires":[[]]},{"id":"5f7a2b73.ee12ec","type":"api-current-state","z":"19a61e2a.75f152","name":"Is home","server":"ed1ce5cc.927bb8","version":1,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":440,"y":300,"wires":[["319b0046.3d0ff"],[]]},{"id":"e3cbf0de.ddb918","type":"comment","z":"19a61e2a.75f152","name":"Sender varsel til mobiltelefon","info":"","x":480,"y":60,"wires":[]},{"id":"ed1ce5cc.927bb8","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

 

Endret av slippern
Fant en bug i flowen...
Skrevet
[{"id":"3fbcc579.1dc12a","type":"inject","z":"760c6da2.02a1b4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 12 * * *","once":false,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":130,"y":120,"wires":[["37d01ae9.869d66"]]},{"id":"dea77fd.b480f8","type":"http request","z":"760c6da2.02a1b4","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://komteksky.norkart.no/komtek.renovasjonwebapi/api/tommekalender/?gatenavn=GATENAVN&gatekode=GATEKODE&husnr=HUSNR","tls":"","persist":false,"proxy":"","authType":"","x":130,"y":240,"wires":[["eb562b71.bc3a4"]]},{"id":"37d01ae9.869d66","type":"change","z":"760c6da2.02a1b4","name":"","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\"Kommunenr\":\"KOMMUNENR\",\"RenovasjonAppKey\":\"APPKEY\",\"OS\":\"Android\",\"Connection\":\"Keep-Alive\",\"Accept-Encoding\":\"gzip\",\"User-Agent\":\"okhttp/3.2.0\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":130,"y":180,"wires":[["dea77fd.b480f8"]]},{"id":"b8a2bfdb.4f1c9","type":"api-call-service","z":"760c6da2.02a1b4","name":"","server":"ed1ce5cc.927bb8","version":1,"debugenabled":false,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.renovasjon_matavfall","data":"{\"datetime\": fraksjonid1.tommedato }","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":160,"y":360,"wires":[[]]},{"id":"eb562b71.bc3a4","type":"change","z":"760c6da2.02a1b4","name":"","rules":[{"t":"set","p":"fraksjonid1.tommedato","pt":"msg","to":"payload[0].Tommedatoer[0]","tot":"msg"},{"t":"set","p":"fraksjonid2.tommedato","pt":"msg","to":"payload[1].Tommedatoer[0]","tot":"msg"},{"t":"set","p":"fraksjonid16.tommedato","pt":"msg","to":"payload[2].Tommedatoer[0]","tot":"msg"},{"t":"set","p":"fraksjonid17.tommedato","pt":"msg","to":"payload[3].Tommedatoer[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":300,"wires":[["b8a2bfdb.4f1c9","64a33f1c.504f7","26eabf7d.2efdd8","7c9d4258.2225a4"]]},{"id":"26eabf7d.2efdd8","type":"api-call-service","z":"760c6da2.02a1b4","name":"","server":"ed1ce5cc.927bb8","version":1,"debugenabled":true,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.renovasjon_restavfall","data":"{\"datetime\": fraksjonid16.tommedato }","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":160,"y":480,"wires":[[]]},{"id":"64a33f1c.504f7","type":"api-call-service","z":"760c6da2.02a1b4","name":"","server":"ed1ce5cc.927bb8","version":1,"debugenabled":true,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.renovasjon_papir","data":"{\"datetime\": fraksjonid2.tommedato }","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":160,"y":420,"wires":[[]]},{"id":"7c9d4258.2225a4","type":"api-call-service","z":"760c6da2.02a1b4","name":"","server":"ed1ce5cc.927bb8","version":1,"debugenabled":true,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.renovasjon_husholdningsplast","data":"{\"datetime\": fraksjonid17.tommedato }","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":160,"y":540,"wires":[[]]},{"id":"ed1ce5cc.927bb8","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

 

Har fikset slik at den tar hver fraksjon inn i en egen input_datetime.

 

image.thumb.png.53beab49caa479343a8739bd5a361559.png

Skrevet
9 timer siden, slippern skrev:

[{"id":"3fbcc579.1dc12a","type":"inject","z":"760c6da2.02a1b4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 12 * * *","once":false,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":130,"y":120,"wires":[["37d01ae9.869d66"]]},{"id":"dea77fd.b480f8","type":"http request","z":"760c6da2.02a1b4","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://komteksky.norkart.no/komtek.renovasjonwebapi/api/tommekalender/?gatenavn=GATENAVN&gatekode=GATEKODE&husnr=HUSNR","tls":"","persist":false,"proxy":"","authType":"","x":130,"y":240,"wires":[["eb562b71.bc3a4"]]},{"id":"37d01ae9.869d66","type":"change","z":"760c6da2.02a1b4","name":"","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\"Kommunenr\":\"KOMMUNENR\",\"RenovasjonAppKey\":\"APPKEY\",\"OS\":\"Android\",\"Connection\":\"Keep-Alive\",\"Accept-Encoding\":\"gzip\",\"User-Agent\":\"okhttp/3.2.0\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":130,"y":180,"wires":[["dea77fd.b480f8"]]},{"id":"b8a2bfdb.4f1c9","type":"api-call-service","z":"760c6da2.02a1b4","name":"","server":"ed1ce5cc.927bb8","version":1,"debugenabled":false,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.renovasjon_matavfall","data":"{\"datetime\": fraksjonid1.tommedato }","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":160,"y":360,"wires":[[]]},{"id":"eb562b71.bc3a4","type":"change","z":"760c6da2.02a1b4","name":"","rules":[{"t":"set","p":"fraksjonid1.tommedato","pt":"msg","to":"payload[0].Tommedatoer[0]","tot":"msg"},{"t":"set","p":"fraksjonid2.tommedato","pt":"msg","to":"payload[1].Tommedatoer[0]","tot":"msg"},{"t":"set","p":"fraksjonid16.tommedato","pt":"msg","to":"payload[2].Tommedatoer[0]","tot":"msg"},{"t":"set","p":"fraksjonid17.tommedato","pt":"msg","to":"payload[3].Tommedatoer[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":300,"wires":[["b8a2bfdb.4f1c9","64a33f1c.504f7","26eabf7d.2efdd8","7c9d4258.2225a4"]]},{"id":"26eabf7d.2efdd8","type":"api-call-service","z":"760c6da2.02a1b4","name":"","server":"ed1ce5cc.927bb8","version":1,"debugenabled":true,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.renovasjon_restavfall","data":"{\"datetime\": fraksjonid16.tommedato }","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":160,"y":480,"wires":[[]]},{"id":"64a33f1c.504f7","type":"api-call-service","z":"760c6da2.02a1b4","name":"","server":"ed1ce5cc.927bb8","version":1,"debugenabled":true,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.renovasjon_papir","data":"{\"datetime\": fraksjonid2.tommedato }","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":160,"y":420,"wires":[[]]},{"id":"7c9d4258.2225a4","type":"api-call-service","z":"760c6da2.02a1b4","name":"","server":"ed1ce5cc.927bb8","version":1,"debugenabled":true,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.renovasjon_husholdningsplast","data":"{\"datetime\": fraksjonid17.tommedato }","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":160,"y":540,"wires":[[]]},{"id":"ed1ce5cc.927bb8","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

 

Har fikset slik at den tar hver fraksjon inn i en egen input_datetime.

 

 

Takk, Tror jeg skjønner. Hos meg ser vel grunnlaget litt annerledes ut. Her er hva jeg har som grunnlag for eksempelvis restavfall (tok ikke med de andre for de er jo like). Da kan jeg ende opp med feler meldinger på dao, eller en streng med datoer. og det er konverteringen av dette til å enten bli en enhet med flere datoer, eller en enhet med første dato jeg ikke får til.

 

Resultatet jeg ender opp med er altså en serie med meldinger med datoer ut fra "move.msg.payload.date", eller en streng med datoer etter "join"

 

Så er sikkert dette en rar måte og gjøre det på, men jeg har nå om ikke annet fått et resultat av fila sortert på type søppel, og er litt fornøyd med det...

 

 

[{"id":"8f4c55dc.520918","type":"inject","z":"a318c51d.29a138","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"name\":\"Restavfall\",\"date\":\"2021-12-17\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-18\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-02\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-16\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-30\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-13\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-27\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-10\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-24\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-08\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-22\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-05\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-19\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-04-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-12-03\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-04-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-18\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-05\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-19\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-03\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-24\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-10\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-27\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-13\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-30\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-16\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-02\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-22\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-08\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-17\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-12-17\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-11-19\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-10-22\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-05-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-09-24\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-08-27\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-30\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-02\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-06-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-07-30\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-11-19\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-09-24\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-06-04\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-10-22\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-09-24\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-08-27\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-30\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-02\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-06-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-05-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-12-17\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-11-19\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4}]","payloadType":"json","x":180,"y":580,"wires":[["386ee4ad.4e547c"]]},{"id":"386ee4ad.4e547c","type":"split","z":"a318c51d.29a138","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":true,"addname":"","x":480,"y":640,"wires":[["13dd80cc.14bebf"]]},{"id":"13dd80cc.14bebf","type":"switch","z":"a318c51d.29a138","name":"","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"Restavfall","vt":"str"},{"t":"eq","v":"Matavfall","vt":"str"},{"t":"eq","v":"Plast","vt":"str"},{"t":"eq","v":"Papir, papp og kartong","vt":"str"},{"t":"eq","v":"Glass- og metallemballasje","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":700,"y":640,"wires":[["53054a07.e52f64"],["d9f3cbcb.d29178"],["b984f0b3.ef20c"],["ff99496c.aa1d08"],["bc01472.69bcab8"]]},{"id":"53054a07.e52f64","type":"change","z":"a318c51d.29a138","name":"","rules":[{"t":"move","p":"payload.name","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":380,"wires":[["61eafcbd.d01db4"]]},{"id":"61eafcbd.d01db4","type":"change","z":"a318c51d.29a138","name":"","rules":[{"t":"move","p":"payload.date","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":420,"wires":[["317384a6.4c7dec"]]},{"id":"317384a6.4c7dec","type":"batch","z":"a318c51d.29a138","name":"","mode":"interval","count":10,"overlap":0,"interval":10,"allowEmptySequence":false,"topics":[],"x":870,"y":460,"wires":[["ca031751.21ce98"]]},{"id":"ca031751.21ce98","type":"join","z":"a318c51d.29a138","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"10","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":990,"y":460,"wires":[["7085436e.78c62c"]]},{"id":"7085436e.78c62c","type":"debug","z":"a318c51d.29a138","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1190,"y":380,"wires":[]},{"id":"1befde2.864f922","type":"api-call-service","z":"a318c51d.29a138","name":"Restaavfall","server":"ec6b4330.077a3","version":1,"debugenabled":false,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.hra_restavfall","data":"{\"date\":{{payload}}}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":true,"x":1170,"y":460,"wires":[[]]},{"id":"ec6b4330.077a3","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

image.thumb.png.cf519e736ff16e047dfff2968403e1dd.png

Skrevet

Fikke en løsning fra Node RED forumet, så da har jeg endelig varsling på avfall igjen 🙂

image.thumb.png.add4f93b3091d132ba0ec742c9da6b05.png

 

[
    {
        "id": "cc42ae3.94b225",
        "type": "function",
        "z": "a318c51d.29a138",
        "name": "",
        "func": "var now = new Date();\n\nvar data = msg.payload;\nif(!data || !Array.isArray(data) || !data.length) {\n    node.warn(\"no data\");\n    return null; //halt flow\n}\n\n//filter the data to today or later AND where name == topic\nvar filtered = data.filter(e => new Date(e.date) >= now && e.name == msg.topic )\n\n//a compare function\nfunction compare( a, b ) {\n  if ( a.date < b.date ) return -1;\n  if ( a.date > b.date ) return 1;\n  return 0;\n}\n//sort data using the compare function\nvar dataSorted = filtered.sort(compare);\n\n//grab the top (earliest) entry - put it in payload\nmsg.payload = dataSorted[0];\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 800,
        "y": 120,
        "wires": [
            [
                "b10b1e1e.bb47f"
            ]
        ]
    }
]

 

  • Like 1

Bli med i samtalen

Du kan publisere innhold nå og registrere deg senere. Hvis du har en konto, logg inn nå for å poste med kontoen din.

Gjest
Skriv svar til emnet...

×   Du har limt inn tekst med formatering.   Lim inn uten formatering i stedet

  Du kan kun bruke opp til 75 smilefjes.

×   Lenken din har blitt bygget inn på siden automatisk.   Vis som en ordinær lenke i stedet

×   Tidligere tekst har blitt gjenopprettet.   Tøm tekstverktøy

×   Du kan ikke lime inn bilder direkte. Last opp eller legg inn bilder fra URL.

×
×
  • Opprett ny...

Viktig informasjon

Vi har plassert informasjonskapsler/cookies på din enhet for å gjøre denne siden bedre. Du kan justere dine innstillinger for informasjonskapsler, ellers vil vi anta at dette er ok for deg.