Skip to content

Latest commit

 

History

History
90 lines (49 loc) · 26.8 KB

README.md

File metadata and controls

90 lines (49 loc) · 26.8 KB

HA_NR_pokemon_go_events

A Nodered flow for Home Assistant to bring in pokemon go events for notification and dash reminders.

Create text and dashboard notification for all pokemon go events.

db82b3aaba1b8fedc2189402929af1d19c5b1717 63e60b5be9205cd27ba68f44a2abf534d1e0785f

This flow utilizes Scraped Duck's scrape of Leek Duck. It also uses google's custom image search to attempt to find the current event's infographic for raids, community days and spotlight hours. Can be omitted if you don't like cloud services.

Prerequisites:

Data is stored locally in NR, without saving to file all data will be deleted on NR restart. You will need access to where your /media folder is located. If you have not setup access you can use the samba addon.

On the same level you will find a folder addon_config inside there will be a node red folder containing settings.js. Make the changes to save to file as shown in the above link.

If you do not have a google cloud account head over to https://console.cloud.google.com/. Click create and create a new project. If you have already set this up for other google services, you can use the same project. Open your project choose api's on the left hand side, then click the enable api's, search for custom image search and enable it.

Now create a search engine. Open the search engine and copy the cx number. Place it in the address below where indicated. Next create an api key, copy it and paste it in the address below. Note: remove the parentheses. Place this address in the pokemon infographic node.

https://www.googleapis.com/customsearch/v1?key=(api key)&cx=(cx key)={{payload}}

Open the programmable search control panel and add the follow settings.

dede02f7d94f624dae5b146686ab2f0df9026d8a

The flow, there are additional instruction in the comments of the flow

3993dec0fffa3a37bebf916751d0941da7d9e883

[{"id":"e754737f50845256","type":"tab","label":"pokemon go","disabled":false,"info":"","env":[]},{"id":"9f987685e35395b5","type":"group","z":"e754737f50845256","name":"","style":{"stroke":"#ffff00","label":true},"nodes":["95ce44e0d545d4cd","e3651cb5f553439c","0286e56d9f9062f4"],"x":74,"y":39,"w":472,"h":142},{"id":"c28abb1cbc191e28","type":"group","z":"e754737f50845256","name":"","style":{"stroke":"#ffff00","label":true},"nodes":["07080663aac0524d","d3a5703096d05846","e4111b72d5735668","c0582807c6e8974a","440aae47dcfbef02","5deead5948952910","fbdf56d07800282e","83880896555098ed"],"x":74,"y":219,"w":1132,"h":222},{"id":"a97ec72269d723fb","type":"group","z":"e754737f50845256","name":"","style":{"stroke":"#ffff00","label":true},"nodes":["67ba21296c0bffcc","4f61d0f9eb9601de"],"x":594,"y":715,"w":312,"h":186},{"id":"6859488729f93951","type":"group","z":"e754737f50845256","name":"","style":{"stroke":"#ffff00","label":true},"nodes":["7c6ec2cf65a6b833","5738bf5719150b72","bb8807e21edfbec4"],"x":1054,"y":1099,"w":372,"h":154},{"id":"b8a361e1b159f87b","type":"group","z":"e754737f50845256","name":"","style":{"stroke":"#ffff00","label":true},"nodes":["a81ebac9597cde08","4fdccce62960d516","089fadc67e154257","c3bbc79b65802fbd"],"x":74,"y":1099,"w":662,"h":174},{"id":"8ec264a037821320","type":"group","z":"e754737f50845256","name":"","style":{"stroke":"#ffff00","label":true},"nodes":["d858e91f0b0d4484","a89e0296940a01cb","c31328d31a4ff8da","0455d9114f80543c","dc0ce687333fc2ea","c3e54aa6c807a9e5","5b60155016a7a155"],"x":74,"y":479,"w":712,"h":202},{"id":"2141323e0d144f6d","type":"group","z":"e754737f50845256","name":"","style":{"stroke":"#ffff00","label":true},"nodes":["89bd87029319573e","b71cda741078c6bf","0914f8ed180c0111","301ed44b1277e3c2","c636d46898184b69"],"x":74,"y":919,"w":1252,"h":142},{"id":"95ce44e0d545d4cd","type":"function","z":"e754737f50845256","g":"9f987685e35395b5","name":"create followed events ","func":"const pokemonEvents = [\"go-battle-league\", \"pokestop-showcase\", \"raid-day\", \"raid-battles\", \"event\", \"pokemon-spotlight-hour\", \"raid-hour\", \"research\", \"community-day\", \"season\", \"research-breakthrough\", \"pokemon-go-fest\", \"ticketed\", \"elite-raids\"];\nflow.set('pokemonEvents', pokemonEvents);\nconst theseTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];\nconst followedEvents = [];\nfor (let i in theseTypes) {\n    let x = theseTypes[i];\n    followedEvents.push(pokemonEvents[x]);\n}\nflow.set('followedEvents', followedEvents);\nnode.status({fill:\"green\",shape:\"dot\",text:\"followed events created\"});\nnode.done;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":140,"wires":[[]]},{"id":"e3651cb5f553439c","type":"inject","z":"e754737f50845256","g":"9f987685e35395b5","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":140,"wires":[["95ce44e0d545d4cd"]]},{"id":"0286e56d9f9062f4","type":"comment","z":"e754737f50845256","g":"9f987685e35395b5","name":"Trigger once when deployed or to update followed events.","info":"","x":310,"y":80,"wires":[]},{"id":"07080663aac0524d","type":"function","z":"e754737f50845256","g":"c28abb1cbc191e28","name":"Send filtered to calader","func":"const followedEvents = flow.get('followedEvents');\nconst leekDuck = msg.payload;\nlet pokemonCalander = [];\n\nfunction nextSunday() {\n    const day = new Date().getDay();\n    const nextSundayAdd = (7 - day) * 24 * 60 * 60 * 1000;\n    const nextSunday = Date.now() + nextSundayAdd;\n    const date = new Date(nextSunday).setHours(23, 59, 59, 0);\n    const midnight = new Date(date);\n    return midnight;\n\n}\n\n\nfor (let i = 0; i < leekDuck.length; i++) {\n    const element = leekDuck[i].eventType;\n    const elementDate = new Date(leekDuck[i].start);\n    const endDate = nextSunday();\n    if (followedEvents.indexOf(element) !== -1 && elementDate < endDate && elementDate > new Date()) {\n        pokemonCalander.push(leekDuck[i]);\n    }\n\n}\n\n\nconst totalCount = pokemonCalander.length;\nvar delay = 0;\nlet i = 0;\nmsg = {};\n\nfunction calanderPush() {\n    setTimeout(function () {\n        if (i < pokemonCalander.length) {\n            msg.heading = pokemonCalander[i].heading;\n            msg.summary = pokemonCalander[i].name;\n\n\n            let start = pokemonCalander[i].start;\n            let endDate = pokemonCalander[i].end;\n            let duration = new Date(endDate).getTime() - new Date(start).getTime();            \n            function localTime(date){\n                if (!date.endsWith(\"Z\")) {\n                    date = date + 'Z';\n                }\n                let x = new Date(date).getTime();\n                let time = new Date(x).toISOString();\n                return time;  \n            }\n\n            function limitHours(date, hours) {\n                const hoursToAdd = hours * 60 * 60 * 1000;\n                let x = new Date(date)\n                let start = x.setTime(x.getTime() + hoursToAdd);\n                return new Date(start).toISOString();\n            }\n\n            let ndStart = localTime(start);\n            let end = limitHours(ndStart, 1);\n            \n            msg.start = ndStart.replace(\"T\", \" \").replace(\".000Z\", \"\");\n            msg.end = end.replace(\"T\", \" \").replace(\".000Z\", \"\");\n            if (duration < 86400000){\n                duration = duration/3600000;\n            } else if (duration >= 86400000){\n                duration = duration/86400000;\n            }\n            msg.duration = duration;\n\n            let image = pokemonCalander[i].image;\n            let link = pokemonCalander[i].link;\n\n            msg.location = `${image},${link}`;\n            msg.midnight = nextSunday();\n            node.send(msg);\n            node.status({ fill: \"green\", shape: \"ring\", text: \"entry \" + (i + 1) + \" of \" + totalCount });\n            delay = 2000;\n            i++;\n            calanderPush();\n        }\n        else {\n            node.status({ fill: \"green\", shape: \"dot\", text: \"done\" })\n            node.done();\n        }\n    }, delay)\n}\n\ncalanderPush();\n","outputs":1,"timeout":0,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\n// node.log(\"start up\");\n// let a = flow.get('pokemonEvents') || undefined;\n// if (a == undefined) {\n//     const pokemonEvents = [\"go-battle-league\", \"pokestop-showcase\", \"raid-day\", \"raid-battles\", \"event\", \"pokemon-spotlight-hour\", \"raid-hour\", \"research\", \"community-day\", \"season\", \"research-breakthrough\", \"pokemon-go-fest\", \"ticketed\"];\n//     flow.set('pokemonEvents', pokemonEvents);\n//     const theseTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];\n//     const followedEvents = [];\n//     for (let i in theseTypes) {\n//         let x = theseTypes[i];\n//         followedEvents.push(pokemonEvents[x]);\n//     }\n//     flow.set('followedEvents', followedEvents);\n// } \n// node.warn(\"start up\");","finalize":"","libs":[],"x":610,"y":340,"wires":[["440aae47dcfbef02","c0582807c6e8974a"]]},{"id":"d3a5703096d05846","type":"inject","z":"e754737f50845256","g":"c28abb1cbc191e28","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"59 23 * * 0","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":340,"wires":[["e4111b72d5735668"]]},{"id":"e4111b72d5735668","type":"http request","z":"e754737f50845256","g":"c28abb1cbc191e28","name":"scrape duck get","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://raw.githubusercontent.com/bigfoott/ScrapedDuck/data/events.min.json","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":380,"y":340,"wires":[["07080663aac0524d"]]},{"id":"c0582807c6e8974a","type":"api-call-service","z":"e754737f50845256","g":"c28abb1cbc191e28","name":"","server":"","version":5,"debugenabled":true,"domain":"calendar","service":"create_event","areaId":[],"deviceId":[],"entityId":["calendar.pogo"],"data":"{\t   \"summary\": heading,\t   \"description\": summary,\t   \"start_date_time\": start,\t   \"end_date_time\": end,\t   \"location\": location\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":900,"y":340,"wires":[[]]},{"id":"440aae47dcfbef02","type":"merge","z":"e754737f50845256","g":"c28abb1cbc191e28","name":"","timeout":"10","x":810,"y":400,"wires":[["5deead5948952910"]]},{"id":"5deead5948952910","type":"function","z":"e754737f50845256","g":"c28abb1cbc191e28","name":"Store this week's events","func":"const upcoming = msg.payload;\n\nflow.set(\"upcoming\", upcoming);\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1010,"y":400,"wires":[["83880896555098ed"]]},{"id":"fbdf56d07800282e","type":"comment","z":"e754737f50845256","g":"c28abb1cbc191e28","name":"Trigger once when deployed, will update on sundays @ 11:59","info":"","x":320,"y":260,"wires":[]},{"id":"83880896555098ed","type":"link out","z":"e754737f50845256","g":"c28abb1cbc191e28","name":"link out 2","mode":"link","links":["0455d9114f80543c"],"x":1165,"y":400,"wires":[]},{"id":"67ba21296c0bffcc","type":"http request","z":"e754737f50845256","g":"a97ec72269d723fb","name":"pokemon infographic","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://www.googleapis.com/customsearch/v1?key=AIzaSyBUKbfWyZghEaZnKN9-KV5HcubIHNpb0hI&cx=e25c43015d8d64ecc&q={{payload}}","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":740,"y":860,"wires":[["89bd87029319573e"]]},{"id":"4f61d0f9eb9601de","type":"comment","z":"e754737f50845256","g":"a97ec72269d723fb","name":"Google image search\\n can be removed\\n connect top output to build text","info":"","x":750,"y":780,"wires":[]},{"id":"7c6ec2cf65a6b833","type":"file","z":"e754737f50845256","g":"6859488729f93951","name":"save image","filename":"/media/pogo/test.jpg","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","x":1330,"y":1140,"wires":[[]]},{"id":"5738bf5719150b72","type":"http request","z":"e754737f50845256","g":"6859488729f93951","name":"get graphic","method":"GET","ret":"bin","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":1150,"y":1140,"wires":[["7c6ec2cf65a6b833"]]},{"id":"bb8807e21edfbec4","type":"comment","z":"e754737f50845256","g":"6859488729f93951","name":"Saves google image\\n remove if image search omitted","info":"","x":1210,"y":1200,"wires":[]},{"id":"a81ebac9597cde08","type":"ha-events-calendar","z":"e754737f50845256","g":"b8a361e1b159f87b","name":"","version":0,"server":"6b1110b5.183a4","exposeAsEntityConfig":"","entityId":"calendar.pogo","filter":"","filterType":"str","eventType":"start","offset":0,"offsetType":"num","offsetUnits":"minutes","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"calendarItem"}],"x":180,"y":1140,"wires":[[]]},{"id":"4fdccce62960d516","type":"change","z":"e754737f50845256","g":"b8a361e1b159f87b","name":"","rules":[{"t":"move","p":"payload.start.dateTime","pt":"msg","to":"data.event.new_state.attributes.start_time","tot":"msg"},{"t":"move","p":"payload.summary","pt":"msg","to":"data.event.new_state.attributes.message","tot":"msg"},{"t":"move","p":"payload.location","pt":"msg","to":"data.event.new_state.attributes.location","tot":"msg"},{"t":"move","p":"payload.description","pt":"msg","to":"data.event.new_state.attributes.description","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1140,"wires":[["301ed44b1277e3c2","c3bbc79b65802fbd"]]},{"id":"089fadc67e154257","type":"comment","z":"e754737f50845256","g":"b8a361e1b159f87b","name":"For start offset, remove trigger\\n connect calendar to change node","info":"","x":240,"y":1220,"wires":[]},{"id":"c3bbc79b65802fbd","type":"debug","z":"e754737f50845256","g":"b8a361e1b159f87b","name":"debug 197","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":1140,"wires":[]},{"id":"d858e91f0b0d4484","type":"function","z":"e754737f50845256","g":"8ec264a037821320","name":"Create sensor for upcoming media card","func":"const upcoming = flow.get(\"upcoming\");\nconst config = \n    {\n    \"title_default\": \"$title\",\n    \"line1_default\": \"$release\",\n    \"line2_default\": \"$day\",\n    \"line3_default\": \"$time\",\n    \"line4_default\": \"$empty\",\n    \"icon\": \"mdi:arrow-down-bold-circle\"\n};\nlet sensorData = [];\n\n\nfor (let i = 0; i < upcoming.length; i++) {\n    const element = upcoming[i];\n    const time = element.start;\n    const title = element.heading;\n    const event = element.summary;\n    const links = element.location.split(',');\n    const image = links[0];\n    const data = {\n        \"title\": title,\n        \"airdate\": time,\n        \"release\": event,\n        \"poster\": image,\n        \"fanart\": image\n    };\n\n    sensorData.push(data);\n\n};\n\nfunction custom_sort(a, b) {\n    return new Date(a.airdate).getTime() - new Date(b.airdate).getTime();\n}\n\nsensorData.sort(custom_sort);\n\nsensorData.unshift(config);\n\nmsg.payload = \"on\";\nmsg.data = sensorData;\nflow.set(\"sensorData\", sensorData);\n\n\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":580,"wires":[["c3e54aa6c807a9e5"]]},{"id":"a89e0296940a01cb","type":"function","z":"e754737f50845256","g":"8ec264a037821320","name":"Remove passed events","func":"const upcoming = flow.get(\"upcoming\");\nconst oldSensorData = flow.get(\"sensorData\");\nconst config =\n{\n    \"title_default\": \"$title\",\n    \"line1_default\": \"$release\",\n    \"line2_default\": \"$day\",\n    \"line3_default\": \"$time\",\n    \"line4_default\": \"$empty\",\n    \"icon\": \"mdi:arrow-down-bold-circle\"\n}\n    ;\nlet sensorData = [];\nconst today = new Date().getDay();\n\nif (oldSensorData.length > 3) {\n    for (let i = 0; i < upcoming.length; i++) {\n        const element = upcoming[i];\n        const eventDay = new Date(element.start).getDay();\n        if (eventDay >= today) {\n\n            const time = element.start;\n            const title = element.heading;\n            const event = element.summary;\n            const links = element.location.split(',');\n            const image = links[0];\n            const data = {\n                \"title\": title,\n                \"airdate\": time,\n                \"release\": event,\n                \"poster\": image,\n                \"fanart\": image\n            };\n\n            sensorData.push(data);\n        }\n\n    }\n\n\n    function custom_sort(a, b) {\n        return new Date(a.airdate).getTime() - new Date(b.airdate).getTime();\n    }\n\n    sensorData.sort(custom_sort);\n\n    sensorData.unshift(config);\n\n    msg.payload = \"on\";\n    msg.data = sensorData;\n    flow.set(\"sensorData\", sensorData);\n\n\n\n    return msg;\n} else {\n    node.done;\n}\n\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":640,"wires":[["c31328d31a4ff8da","c3e54aa6c807a9e5"]]},{"id":"c31328d31a4ff8da","type":"debug","z":"e754737f50845256","g":"8ec264a037821320","name":"debug 198","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":640,"wires":[]},{"id":"0455d9114f80543c","type":"link in","z":"e754737f50845256","g":"8ec264a037821320","name":"link in 2","links":["83880896555098ed"],"x":115,"y":580,"wires":[["d858e91f0b0d4484"]]},{"id":"dc0ce687333fc2ea","type":"comment","z":"e754737f50845256","g":"8ec264a037821320","name":"Create sensor for upcoming media card","info":"","x":250,"y":520,"wires":[]},{"id":"c3e54aa6c807a9e5","type":"ha-sensor","z":"e754737f50845256","g":"8ec264a037821320","name":"","entityConfig":"304bb5a55719ad2f","version":0,"state":"payload","stateType":"msg","attributes":[{"property":"data","value":"data","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":650,"y":580,"wires":[[]],"server":""},{"id":"5b60155016a7a155","type":"inject","z":"e754737f50845256","g":"8ec264a037821320","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"00 12 * * 2,3,4,5,6,0","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":190,"y":640,"wires":[["a89e0296940a01cb"]]},{"id":"89bd87029319573e","type":"function","z":"e754737f50845256","g":"2141323e0d144f6d","name":"build text","func":"const message = flow.get(\"pogoTextMessage\");\nconst title = flow.get(\"pogoTextTitle\");\nconst start = flow.get(\"pogoTextStart\")\nconst links = flow.get(\"pogoTextLinks\");\nlet image = links[0];\nlet site = links[1];\n\n\nif (msg.payload.items != undefined) {\n    const pokemonArray = msg.payload.items;\n    const imageTypes = ['.jpg', '.jpeg', '.png', '.webp']\n    const found = pokemonArray.find((element) => element.pagemap.cse_image[0].src.indexOf('http') !== -1\n        && imageTypes.some(el => element.pagemap.cse_image[0].src.includes(el)));\n    image = found.pagemap.cse_image[0].src;\n    let msg2 = { url: image };\n    site = found.pagemap.cse_image[0].src;\n    node.send([null, msg2]);\n}\n\nmsg = {};\nmsg.message = message;\nmsg.title = title;\nmsg.start = start;\nmsg.image = image;\nmsg.site = site;\n\nreturn [msg, null];","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":1020,"wires":[["b71cda741078c6bf"],["5738bf5719150b72"]]},{"id":"b71cda741078c6bf","type":"api-call-service","z":"e754737f50845256","g":"2141323e0d144f6d","name":"","server":"","version":5,"debugenabled":true,"domain":"notify","service":"mobile_app_pixel_7","areaId":[],"deviceId":[],"entityId":[],"data":"{\t   \"message\": message & '\\\\n' & $moment(start).local().format(\"[Today @ ] LT\"),\t   \"title\": title,\t   \"data\": {\t       \"image\": image,\t       \"clickAction\": site,\t       \"channel\": \"pogo\",\t       \"ttl\": 0,\t       \"prority\": \"high\"\t        }\t    }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1190,"y":1020,"wires":[[]]},{"id":"0914f8ed180c0111","type":"trigger-state","z":"e754737f50845256","g":"2141323e0d144f6d","name":"","server":"","version":4,"inputs":0,"outputs":2,"exposeAsEntityConfig":"011621ce5f7b8be4","entityId":"calendar.pogo","entityIdType":"exact","debugEnabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"customOutputs":[],"outputInitially":false,"stateType":"str","enableInput":false,"x":220,"y":1020,"wires":[["c3bbc79b65802fbd","301ed44b1277e3c2"],[]]},{"id":"301ed44b1277e3c2","type":"function","z":"e754737f50845256","g":"2141323e0d144f6d","name":"calander parse","func":"if (msg.payload == \"on\") {\n    const message = msg.data.event.new_state.attributes.message;\n    flow.set(\"pogoTextMessage\", message);\n\n    const title = msg.data.event.new_state.attributes.description;\n    flow.set(\"pogoTextTitle\", title);\n\n    let start = msg.data.event.new_state.attributes.start_time;\n    flow.set(\"pogoTextStart\", start);\n\n    const links = msg.data.event.new_state.attributes.location.split(',');\n    flow.set(\"pogoTextLinks\", links);\n\n    const month = [\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"];\n\n\n    function pokemon(regex, length) {\n        let text = title;\n        regex.test(text);\n        let index = regex.lastIndex - length;\n        let slice = text.slice(index);\n        let pokemon = text.replace(slice, '');\n        return pokemon;\n    }\n\n    // const days = ['Sun', 'Mon', 'Tues', 'Wed', \n    //             'Thurs', 'Fri', 'Sat'];\n    // const months = ['Jan', 'Feb', 'Mar', 'Apr', \n    //             'May', 'June', 'July', 'Aug', 'Sep', \n    //             'Oct', 'Nov', 'Dec'];\n\n    start = new Date(start).toLocaleDateString('en-US');\n\n    let monthYear = month[new Date(start).getMonth()] + \" \" + new Date(start).getFullYear();\n\n        let infographic = undefined;\n    let i = 10\n    if(title.search(/spotlight/i) !== -1){\n        let x = new RegExp('spotlight', 'gi');\n        //let i = 10;\n        infographic = pokemon(x, i) + ' spotlight hours ' + monthYear;\n    }\n    else if(title.search(/raid hour/i) !== -1){\n        let x = new RegExp('raid hour', 'gi');\n        //let i = 5;\n        infographic = pokemon(x, i) + ' raid info ' + monthYear;\n    }\n    else if (title.search(/raid/i) !== -1) {\n        let x = new RegExp(' in ', 'gi');\n        i = 5;\n        infographic = pokemon(x, i) + ' raid info ' + monthYear;\n    }\n    else if (title.search(/community/i) !== -1){\n        let x = new RegExp('community', 'gi');\n        //let i = 10;\n        infographic = pokemon(x, i) + ' community day infographic ' + monthYear;\n    }\n\n    msg = {};\n    \n    if(infographic != undefined){\n        msg.payload = infographic;\n        return [msg, null];\n    }\n    else{\n        msg.payload = 'on';\n        return [null, msg];\n    }\n}\n","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":1020,"wires":[["67ba21296c0bffcc"],["89bd87029319573e"]]},{"id":"c636d46898184b69","type":"comment","z":"e754737f50845256","g":"2141323e0d144f6d","name":"Build text messages","info":"","x":190,"y":960,"wires":[]},{"id":"304bb5a55719ad2f","type":"ha-entity-config","server":"","deviceConfig":"","name":"pogo test","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"pogo test"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false},{"id":"011621ce5f7b8be4","type":"ha-entity-config","server":"","deviceConfig":"","name":"exposed as for 011621ce5f7b8be4","version":6,"entityType":"switch","haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"resend":false}]

Note: The calendar node loads the next 15 minutes after it was deployed. So if you deploy the node, set an event to start 5 minutes later, the calendar node will NOT pick it up. It is setup using a trigger node which will pick up an event almost instantly vs waiting 15 minutes.

If you want the event text at the event time use the trigger node. If you want an advanced notice use the calendar node and set the offset option. You can also use both to get advanced and time of texts. Be warned that pokemoan go fest alerts can come in the middle of the night, this is a global event and will reflect local times of the actual event.

Texts are setup for android phones. It will create a pokemon channel. You can set a custom message tone. For pokemon go sounds see https://www.zedge.net/find/ringtones/pokemongo.

To set which events are followed, in the create followed events node you will find

const theseTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

Each number represents an event type, add only the number of the events you want to follow. Use the chart below for types.

069c50f483619aaa776ea20c4c0d52cda972929e

ex if you only wanted go battle league, raid battles, and pokemon-spotlight-hour. You would use

const theseTypes = [0, 3, 5]

Create a config for the sensor node and give it a name. Use that entity in the code below.

To add the upcoming media card use:


  - type: custom:upcoming-media-card
    entity: sensor.pogo_test
    tap_action:
      action: more-info
    title: null
    image_style: fanart
    date: mm/dd