Change RGB light color based on tidal sensor info

Hello, first post. Please forgive my lack of or misuse of terminology.

Ill explain what I am trying to do.
Provide what I have accomplished thus far (don’t know that any of it will stay)
And at the very end introduce myself if your interested.

**My goal is to have some RGB strip lights change color based on the current tide.
Green 2 hours before and after high tide, Red 2 hours before and after low tide, yellow in between tides with some indication in color if the tide is rising or falling **

I am using node-red but am open to any integration, script, etc.

I currently have 2 sensors getting tidal data. I know there is another for a fee/credits but I would prefer not to have to spend the $ if I dont have to.

  1. scrape sensor by blackshoals -https://community.home-assistant.io/t/tide-times/9045/96
sensor:
- platform: scrape
    resource: https://tides4fishing.com/us/florida-gulf-coast/hudson-hudson-creek#_tides
    name: Tide
    select: "#brujula_mareas_texto_movil"
    scan_interval: 10   

This returns a message like this:
The water level is rising. There are 52 minutes until high tide.

  1. noaa_tides
sensor:  
- platform: noaa_tides
    station_id: 8727061

This returns a message like this:
High tide at 3:58 PM

Below is what I have put together so far, when I started to get my head around all the variables I decided to come here and say Hi/Help. Yes its ugly, yes there has to be much better ways and that’s why I am here. I look forward to suggestions and direction.

    {
        "id": "a067a6aa20faf4c4",
        "type": "tab",
        "label": "Tide",
        "disabled": false,
        "info": ""
    },
    {
        "id": "64273919e14f6e1b",
        "type": "debug",
        "z": "a067a6aa20faf4c4",
        "name": "rising",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1370,
        "y": 360,
        "wires": []
    },
    {
        "id": "e1cc22eefcd2c456",
        "type": "server-state-changed",
        "z": "a067a6aa20faf4c4",
        "name": "The water level is",
        "server": "b3217b27.630be8",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.tide",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "false",
        "halt_if_type": "entity",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "for": "5",
        "forType": "num",
        "forUnits": "seconds",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 380,
        "y": 180,
        "wires": [
            [
                "a2f84b33da315518"
            ],
            [
                "cbc79b95f8d0167b"
            ]
        ]
    },
    {
        "id": "c9f36cba3da7a076",
        "type": "change",
        "z": "a067a6aa20faf4c4",
        "name": "2 hours",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "The water level is  rising.",
                "fromt": "str",
                "to": "Rising",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "There are 2 hours",
                "fromt": "str",
                "to": "2",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "high",
                "fromt": "str",
                "to": "High",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "and",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "minutes",
                "fromt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "until",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "tide",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "The water level is  falling.",
                "fromt": "str",
                "to": "Falling",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 680,
        "y": 400,
        "wires": [
            [
                "71c27971e3c7b20b",
                "318b421756743ab6"
            ]
        ]
    },
    {
        "id": "631216ba50ace76f",
        "type": "api-call-service",
        "z": "a067a6aa20faf4c4",
        "name": "",
        "server": "ea33da29.578668",
        "version": 3,
        "debugenabled": true,
        "service_domain": "homeassistant",
        "service": "turn_on",
        "entityId": "light.office_light",
        "data": "{\"brightness\":255,\"rgb_color\":[255,255,255],\"transition\":6}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1140,
        "y": 360,
        "wires": [
            [
                "64273919e14f6e1b"
            ]
        ]
    },
    {
        "id": "71c27971e3c7b20b",
        "type": "switch",
        "z": "a067a6aa20faf4c4",
        "name": "Rising",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "Rising",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 910,
        "y": 360,
        "wires": [
            [
                "631216ba50ace76f"
            ]
        ]
    },
    {
        "id": "8c241b5d5b3c291c",
        "type": "inject",
        "z": "a067a6aa20faf4c4",
        "name": "Rising",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "The water level is  rising.",
        "payloadType": "str",
        "x": 370,
        "y": 360,
        "wires": [
            [
                "c9f36cba3da7a076"
            ]
        ]
    },
    {
        "id": "318b421756743ab6",
        "type": "switch",
        "z": "a067a6aa20faf4c4",
        "name": "Falling",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "Falling",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 910,
        "y": 440,
        "wires": [
            [
                "25e61f0bbba5ac1a"
            ]
        ]
    },
    {
        "id": "25e61f0bbba5ac1a",
        "type": "api-call-service",
        "z": "a067a6aa20faf4c4",
        "name": "",
        "server": "ea33da29.578668",
        "version": 3,
        "debugenabled": true,
        "service_domain": "homeassistant",
        "service": "turn_on",
        "entityId": "light.office_light",
        "data": "{\"brightness\":255,\"rgb_color\":[252,13,13],\"transition\":6}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1140,
        "y": 440,
        "wires": [
            [
                "83ea2b445218f6ed"
            ]
        ]
    },
    {
        "id": "708f05822489251e",
        "type": "inject",
        "z": "a067a6aa20faf4c4",
        "name": "Falling",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "The water level is  falling.",
        "payloadType": "str",
        "x": 370,
        "y": 440,
        "wires": [
            [
                "c9f36cba3da7a076"
            ]
        ]
    },
    {
        "id": "a2f84b33da315518",
        "type": "debug",
        "z": "a067a6aa20faf4c4",
        "name": "true",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 650,
        "y": 100,
        "wires": []
    },
    {
        "id": "cbc79b95f8d0167b",
        "type": "debug",
        "z": "a067a6aa20faf4c4",
        "name": "false",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 650,
        "y": 160,
        "wires": []
    },
    {
        "id": "83ea2b445218f6ed",
        "type": "debug",
        "z": "a067a6aa20faf4c4",
        "name": "falling",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1370,
        "y": 440,
        "wires": []
    },
    {
        "id": "4ee15a25314a8a3f",
        "type": "comment",
        "z": "a067a6aa20faf4c4",
        "name": "scrape sensor",
        "info": "",
        "x": 170,
        "y": 180,
        "wires": []
    },
    {
        "id": "ee7a34330f9db9d7",
        "type": "comment",
        "z": "a067a6aa20faf4c4",
        "name": "testing variables",
        "info": "",
        "x": 160,
        "y": 400,
        "wires": []
    },
    {
        "id": "b3217b27.630be8",
        "type": "server",
        "name": "Home Assistant",
        "version": 1,
        "legacy": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true
    },
    {
        "id": "ea33da29.578668",
        "type": "server",
        "name": "Home Assistant",
        "version": 1,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true
    }
]

Thank you.

Intro:
Hello, I’ve been big into a connected home for many years using wifi bulbs, plugs, switches with Google Assistant devices. As my connected Home grew so did all of the conflicts with various hardware makes/models/apps & general chaos and confusion.

After much frustration I decided to go with Home Assistant and I am having allot of fun turning my connected home into a smart home with HA & Hubitat.
The possibilities seem endless now and I am really digging the fact that I don’t need to rely on Google as the backbone to my setup.

Currently I have a bunch of Sengled lights and plugs, some Yale locks, Nest Cameras, Nest Thermostat, Google WIFI. Google assistants in most rooms.

In my free time I love to play pc games and I am currently enjoying Satisfactory. I live on the Gulf of Mexico so boating & fishing is allots of fun too. Oh… I also like beer.

Thanks for reading!

Hi there, It seems that what you have deployed does what you intend to in a simple way. Is there anything that is not being satisfied with the current setup?

Also I have seen a free api that could provide some more details for you to work

Thank you for your reply. My current set up doesn’t result in the desired outcome, its not even close.
I am most interested in suggestions or directions to help accomplish.

I will look at the API you suggested.

Thank you

Can you share the longitude and latitude of the location, you want to check the tidal info?

I will check with the api to build a flow.

Latitude 28.364449
Longitude -82.693436

Thank you again.

Can you confirm the following values of high and low tide are correct with respect to your location?

[
  {
    "timestamp": 1636442920,
    "datetime": "Tuesday November 09, 2021 02:28:40 (am)",
    "height": 0.550044409981898,
    "state": "HIGH TIDE"
  },
  {
    "timestamp": 1636470322,
    "datetime": "Tuesday November 09, 2021 10:05:22 (am)",
    "height": -0.6457568106554901,
    "state": "LOW TIDE"
  },
  {
    "timestamp": 1636495914,
    "datetime": "Tuesday November 09, 2021 17:11:54 (pm)",
    "height": 0.13371140233325643,
    "state": "HIGH TIDE"
  },
  {
    "timestamp": 1636511349,
    "datetime": "Tuesday November 09, 2021 21:29:09 (pm)",
    "height": -0.006303554584491366,
    "state": "LOW TIDE"
  }
]

They are correct.

Please see if this works. change the light entity id before deploying. I will explain the details if this works.

[{"id":"d5bf472ad615c7eb","type":"inject","z":"51045e07.bbf87","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"time","v":"","vt":"date"}],"repeat":"60","crontab":"","once":true,"onceDelay":"20","topic":"","payloadType":"date","x":190,"y":2020,"wires":[["89a4745dcdb2eff3"]]},{"id":"89a4745dcdb2eff3","type":"http request","z":"51045e07.bbf87","name":"post to HttpBin","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://tides4fishing.com/us/florida-gulf-coast/hudson-hudson-creek#_tides","tls":"","persist":false,"proxy":"","authType":"","x":360,"y":2020,"wires":[["2670a67523ce0ddd","3b1151c65950c78e","e314821f31e7f8a2","65f0bc9535ece8db"]]},{"id":"2670a67523ce0ddd","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2 > strong:nth-child(2)","ret":"text","as":"multi","x":530,"y":2020,"wires":[["76be867981fbdd68"]]},{"id":"3b1151c65950c78e","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2 > span","ret":"text","as":"multi","x":530,"y":2060,"wires":[["6d5e7cddba1bbc51"]]},{"id":"e314821f31e7f8a2","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2 > strong:nth-child(3)","ret":"text","as":"multi","x":530,"y":2100,"wires":[["fa3211636fc0c2a5"]]},{"id":"65f0bc9535ece8db","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2","ret":"text","as":"multi","x":530,"y":1980,"wires":[["587dacbc7533d5e2"]]},{"id":"76be867981fbdd68","type":"split","z":"51045e07.bbf87","name":"","splt":"and","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"time","x":650,"y":2020,"wires":[["26ae40184bb64f6b"]]},{"id":"6d5e7cddba1bbc51","type":"function","z":"51045e07.bbf87","name":"","func":"if (msg.payload.includes(\"rising\")){\n    flow.set(\"water_status\",\"rising\")\n}\nelse {\n    flow.set(\"water_status\",\"falling\")\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":2060,"wires":[[]]},{"id":"fa3211636fc0c2a5","type":"function","z":"51045e07.bbf87","name":"","func":"if (msg.payload.includes(\"high\")){\n    flow.set(\"tide_status\",\"high\")\n}\nelse {\n    flow.set(\"tide_status\",\"low\")\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":2100,"wires":[[]]},{"id":"587dacbc7533d5e2","type":"switch","z":"51045e07.bbf87","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":" high tide ","vt":"str"},{"t":"cont","v":" low tide ","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":1980,"wires":[["ffe32b0781ec1112"],["e212d332496a9f58"]]},{"id":"26ae40184bb64f6b","type":"join","z":"51045e07.bbf87","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"3","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":770,"y":2020,"wires":[["f15cb6d06eefe96b"]]},{"id":"ffe32b0781ec1112","type":"function","z":"51045e07.bbf87","name":"High Tide Now ","func":"    var tide_status = flow.get(\"tide_status\")\n    msg.payload = {\n        \"brightness\": 255,\n        \"rgb_color\": [\n            0,\n            255,\n            0\n        ],\n        \"transition\": 6\n    }\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)\n    return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":1940,"wires":[["06569ceaba7b0328"]]},{"id":"e212d332496a9f58","type":"function","z":"51045e07.bbf87","name":"Low Tide Now","func":"    var tide_status = flow.get(\"tide_status\")\n    msg.payload = {\n        \"brightness\": 255,\n        \"rgb_color\": [\n            255,\n            0,\n            0\n        ],\n        \"transition\": 6\n    }\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)\n    return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":1980,"wires":[["06569ceaba7b0328"]]},{"id":"f15cb6d06eefe96b","type":"delay","z":"51045e07.bbf87","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":900,"y":2020,"wires":[["bc60790eae250cab"]]},{"id":"06569ceaba7b0328","type":"api-call-service","z":"51045e07.bbf87","name":"Light","server":"d177950.2a5aa68","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.10effbf2_bb8e1f28","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1170,"y":2020,"wires":[[]]},{"id":"bc60790eae250cab","type":"function","z":"51045e07.bbf87","name":"","func":"var x = msg.payload.length\nvar tide_status = flow.get(\"tide_status\")\nvar water_status = flow.get(\"water_status\")\nvar hour = 0\nvar minutes = 0\nvar change_time = parseInt(flow.get(\"change_time\"))\nvar change_diff = msg.time - change_time\nvar tide_past = flow.get(\"tide_past\")\nif (x == 1 && msg.payload[0].includes(\"hour\")) {\n    hour = parseInt(msg.payload[0])\n} else if (x == 1 && msg.payload[0].includes(\"minute\")) {\n    minutes = parseInt(msg.payload[0])\n} else if (x == 2 && msg.payload[0].includes(\"hour\")) {\n    hour = parseInt(msg.payload[0])\n    minutes = parseInt(msg.payload[1])\n} else {\n    hour = parseInt(msg.payload[1])\n    minutes = parseInt(msg.payload[0])\n}\nvar time_remain = hour * 60 + minutes\nif (time_remain < 120 && tide_status == \"high\") {\n// Setup for 2 hours before High Tide\n    msg.payload = {\n        \"brightness\": 255,\n        \"rgb_color\": [\n            0,\n            255,\n            0\n        ],\n        \"transition\": 6\n    }\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)\n} else if (time_remain < 120 && tide_status == \"low\") {\n// Setup for 2 hours before Low Tide\n    msg.payload = {\n        \"brightness\": 255,\n        \"rgb_color\": [\n            255,\n            0,\n            0\n        ],\n        \"transition\": 6\n    }\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)\n} else if (time_remain > 120 && change_diff < 7200000 && tide_past == \"high\") {\n// Setup for 2 hours After High Tide\n    msg.payload = {\n        \"brightness\": 255,\n        \"rgb_color\": [\n            0,\n            255,\n            0\n        ],\n        \"transition\": 6\n    }\n} else if (time_remain > 120 && change_diff < 7200000 && tide_past == \"low\") {\n// Setup for 2 hours after Low Tide\n    msg.payload = {\n        \"brightness\": 255,\n        \"rgb_color\": [\n            255,\n            0,\n            0\n        ],\n        \"transition\": 6\n    }\n} else if (time_remain > 120 && change_diff > 7200000 && water_status == \"rising\") {\n// Setup for Rising Tide Between High And Low\n    msg.payload = {\n        \"brightness\": 255,\n        \"rgb_color\": [\n            255,\n            255,\n            0\n        ],\n        \"transition\": 6\n    }\n} else if (time_remain > 120 && change_diff > 7200000 && water_status == \"falling\") {\n// Setup for Falling Tide Between High And Low\n    msg.payload = {\n        \"brightness\": 255,\n        \"rgb_color\": [\n            255,\n            255,\n            0\n        ],\n        \"transition\": 6\n    }\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1040,"y":2020,"wires":[["06569ceaba7b0328"]]},{"id":"d177950.2a5aa68","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

imported, no errors, light turns on but no color change.

This looks amazing btw.

1 Like

Hi there. Please try the below code, dont forget to change the entity-id of light

[{"id":"d5bf472ad615c7eb","type":"inject","z":"51045e07.bbf87","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"time","v":"","vt":"date"}],"repeat":"60","crontab":"","once":true,"onceDelay":"20","topic":"","payloadType":"date","x":190,"y":2020,"wires":[["89a4745dcdb2eff3"]]},{"id":"89a4745dcdb2eff3","type":"http request","z":"51045e07.bbf87","name":"post to HttpBin","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://tides4fishing.com/us/florida-gulf-coast/hudson-hudson-creek#_tides","tls":"","persist":false,"proxy":"","authType":"","x":360,"y":2020,"wires":[["2670a67523ce0ddd","3b1151c65950c78e","e314821f31e7f8a2","65f0bc9535ece8db"]]},{"id":"2670a67523ce0ddd","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2 > strong:nth-child(2)","ret":"text","as":"multi","x":530,"y":2020,"wires":[["76be867981fbdd68"]]},{"id":"3b1151c65950c78e","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2 > span","ret":"text","as":"multi","x":530,"y":2060,"wires":[["6d5e7cddba1bbc51"]]},{"id":"e314821f31e7f8a2","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2 > strong:nth-child(3)","ret":"text","as":"multi","x":530,"y":2100,"wires":[["fa3211636fc0c2a5"]]},{"id":"65f0bc9535ece8db","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2","ret":"text","as":"multi","x":530,"y":1980,"wires":[["587dacbc7533d5e2"]]},{"id":"76be867981fbdd68","type":"split","z":"51045e07.bbf87","name":"","splt":"and","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"time","x":650,"y":2020,"wires":[["26ae40184bb64f6b"]]},{"id":"6d5e7cddba1bbc51","type":"function","z":"51045e07.bbf87","name":"","func":"if (msg.payload.includes(\"rising\")){\n    flow.set(\"water_status\",\"rising\")\n}\nelse {\n    flow.set(\"water_status\",\"falling\")\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":2060,"wires":[[]]},{"id":"fa3211636fc0c2a5","type":"function","z":"51045e07.bbf87","name":"","func":"if (msg.payload.includes(\"high\")){\n    flow.set(\"tide_status\",\"high\")\n}\nelse {\n    flow.set(\"tide_status\",\"low\")\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":2100,"wires":[[]]},{"id":"587dacbc7533d5e2","type":"switch","z":"51045e07.bbf87","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":" high tide ","vt":"str"},{"t":"cont","v":" low tide ","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":1980,"wires":[["ffe32b0781ec1112"],["e212d332496a9f58"]]},{"id":"26ae40184bb64f6b","type":"join","z":"51045e07.bbf87","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"3","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":770,"y":2020,"wires":[["f15cb6d06eefe96b"]]},{"id":"ffe32b0781ec1112","type":"function","z":"51045e07.bbf87","name":"High Tide Now ","func":"    var tide_status = flow.get(\"tide_status\")\n    msg.brightness = 255\n    msg.color = \"green\"\n    msg.transition = 6\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)\n    return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":1940,"wires":[["06569ceaba7b0328"]]},{"id":"e212d332496a9f58","type":"function","z":"51045e07.bbf87","name":"Low Tide Now","func":"    var tide_status = flow.get(\"tide_status\")\n    msg.brightness = 255\n    msg.color = \"red\"\n    msg.transition = 6\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)\n    return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":1980,"wires":[["06569ceaba7b0328"]]},{"id":"f15cb6d06eefe96b","type":"delay","z":"51045e07.bbf87","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":900,"y":2020,"wires":[["bc60790eae250cab"]]},{"id":"06569ceaba7b0328","type":"api-call-service","z":"51045e07.bbf87","name":"Light","server":"d177950.2a5aa68","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.10effbf2_bb8e1f28","data":"{\"brightness\":\"{{brightness}}\",\"color_name\":\"{{color}}\",\"transition\":\"{{transition}}\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1170,"y":2020,"wires":[[]]},{"id":"bc60790eae250cab","type":"function","z":"51045e07.bbf87","name":"","func":"var x = msg.payload.length\nvar tide_status = flow.get(\"tide_status\")\nvar water_status = flow.get(\"water_status\")\nvar hour = 0\nvar minutes = 0\nvar change_time = parseInt(flow.get(\"change_time\"))\nvar change_diff = msg.time - change_time\nvar tide_past = flow.get(\"tide_past\")\nif (x == 1 && msg.payload[0].includes(\"hour\")) {\n    hour = parseInt(msg.payload[0])\n} else if (x == 1 && msg.payload[0].includes(\"minute\")) {\n    minutes = parseInt(msg.payload[0])\n} else if (x == 2 && msg.payload[0].includes(\"hour\")) {\n    hour = parseInt(msg.payload[0])\n    minutes = parseInt(msg.payload[1])\n} else {\n    hour = parseInt(msg.payload[1])\n    minutes = parseInt(msg.payload[0])\n}\nvar time_remain = hour * 60 + minutes\nif (time_remain < 120 && tide_status == \"high\") {\n// Setup for 2 hours before High Tide\n    msg.brightness = 255\n    msg.color = \"green\"\n    msg.transition = 6\n    if(time_remain < 3){\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)        \n    }\n} else if (time_remain < 120 && tide_status == \"low\") {\n// Setup for 2 hours before Low Tide\n    msg.brightness = 255\n    msg.color = \"red\"\n    msg.transition = 6\n    if(time_remain < 3){\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)        \n    }\n} else if (time_remain > 120 && change_diff < 7200000 && tide_past == \"high\") {\n// Setup for 2 hours After High Tide\n    msg.brightness = 255\n    msg.color = \"green\"\n    msg.transition = 6\n} else if (time_remain > 120 && change_diff < 7200000 && tide_past == \"low\") {\n// Setup for 2 hours after Low Tide\n    msg.brightness = 255\n    msg.color = \"red\"\n    msg.transition = 6\n} else if (time_remain > 120 && change_diff > 7200000 && water_status == \"rising\") {\n// Setup for Rising Tide Between High And Low\n    msg.brightness = 255\n    msg.color = \"yellow\"\n    msg.transition = 6\n} else if (time_remain > 120 && change_diff > 7200000 && water_status == \"falling\") {\n// Setup for Falling Tide Between High And Low\n    msg.brightness = 255\n    msg.color = \"yellow\"\n    msg.transition = 6\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1040,"y":2020,"wires":[["06569ceaba7b0328"]]},{"id":"d177950.2a5aa68","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

light no longer turns on, and looks like this is being sent to light.

array[2]

0: "6 hours "

1: " 20 minutes"

Whereas before it was getting brightness color value but not setting them.

Hi, I think you are on the right track, but the example flow is running an http request every minute. Not ideal for your network load and the provider’s API. My original scrape sensor is only triggered when I ask Google Home for the tide, so only a few times a week.

My suggestion would be to abstract the flow a bit and make the HTTP request once a day to store the tide times in an array, then run a function that compares the current time to those tide time variables and adjusts the light.

Please try this

[{"id":"d5bf472ad615c7eb","type":"inject","z":"51045e07.bbf87","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"time","v":"","vt":"date"}],"repeat":"60","crontab":"","once":true,"onceDelay":"20","topic":"","payloadType":"date","x":190,"y":2020,"wires":[["89a4745dcdb2eff3"]]},{"id":"89a4745dcdb2eff3","type":"http request","z":"51045e07.bbf87","name":"post to HttpBin","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://tides4fishing.com/us/florida-gulf-coast/hudson-hudson-creek#_tides","tls":"","persist":false,"proxy":"","authType":"","x":360,"y":2020,"wires":[["2670a67523ce0ddd","3b1151c65950c78e","e314821f31e7f8a2","65f0bc9535ece8db"]]},{"id":"2670a67523ce0ddd","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2 > strong:nth-child(2)","ret":"text","as":"multi","x":530,"y":2020,"wires":[["76be867981fbdd68"]]},{"id":"3b1151c65950c78e","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2 > span","ret":"text","as":"multi","x":530,"y":2060,"wires":[["6d5e7cddba1bbc51"]]},{"id":"e314821f31e7f8a2","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2 > strong:nth-child(3)","ret":"text","as":"multi","x":530,"y":2100,"wires":[["fa3211636fc0c2a5"]]},{"id":"65f0bc9535ece8db","type":"html","z":"51045e07.bbf87","name":"ok","property":"","outproperty":"payload","tag":"#noprint1 > div:nth-child(20) > div.grafico_estado_actual_fondo > div.grafico_estado_actual_texto > div.brujula_mareas_texto_pc.grafico_estado_actual_texto2","ret":"text","as":"multi","x":530,"y":1980,"wires":[["587dacbc7533d5e2"]]},{"id":"76be867981fbdd68","type":"split","z":"51045e07.bbf87","name":"","splt":"and","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"time","x":650,"y":2020,"wires":[["26ae40184bb64f6b"]]},{"id":"6d5e7cddba1bbc51","type":"function","z":"51045e07.bbf87","name":"","func":"if (msg.payload.includes(\"rising\")){\n    flow.set(\"water_status\",\"rising\")\n}\nelse {\n    flow.set(\"water_status\",\"falling\")\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":2060,"wires":[[]]},{"id":"fa3211636fc0c2a5","type":"function","z":"51045e07.bbf87","name":"","func":"if (msg.payload.includes(\"high\")){\n    flow.set(\"tide_status\",\"high\")\n}\nelse {\n    flow.set(\"tide_status\",\"low\")\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":2100,"wires":[[]]},{"id":"587dacbc7533d5e2","type":"switch","z":"51045e07.bbf87","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":" high tide ","vt":"str"},{"t":"cont","v":" low tide ","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":1980,"wires":[["ffe32b0781ec1112"],["e212d332496a9f58"]]},{"id":"26ae40184bb64f6b","type":"join","z":"51045e07.bbf87","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"3","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":770,"y":2020,"wires":[["f15cb6d06eefe96b"]]},{"id":"ffe32b0781ec1112","type":"function","z":"51045e07.bbf87","name":"High Tide Now ","func":"    var tide_status = flow.get(\"tide_status\")\n    msg.brightness = 255\n    msg.color = \"green\"\n    msg.transition = 6\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)\n    return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":1940,"wires":[["06569ceaba7b0328"]]},{"id":"e212d332496a9f58","type":"function","z":"51045e07.bbf87","name":"Low Tide Now","func":"    var tide_status = flow.get(\"tide_status\")\n    msg.brightness = 255\n    msg.color = \"red\"\n    msg.transition = 6\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)\n    return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":1980,"wires":[["06569ceaba7b0328"]]},{"id":"f15cb6d06eefe96b","type":"delay","z":"51045e07.bbf87","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":900,"y":2020,"wires":[["bc60790eae250cab"]]},{"id":"06569ceaba7b0328","type":"api-call-service","z":"51045e07.bbf87","name":"Light","server":"d177950.2a5aa68","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.10effbf2_bb8e1f28","data":"{\"brightness\":\"{{brightness}}\",\"color_name\":\"{{color}}\",\"transition\":\"{{transition}}\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1170,"y":2020,"wires":[[]]},{"id":"bc60790eae250cab","type":"function","z":"51045e07.bbf87","name":"","func":"var x = msg.payload.length\nvar tide_status = flow.get(\"tide_status\")\nvar water_status = flow.get(\"water_status\")\nvar hour = 0\nvar minutes = 0\nvar change_time = parseInt(flow.get(\"change_time\"))\nvar change_diff1 = msg.time - change_time\nvar tide_past = flow.get(\"tide_past\")\nif (x == 1 && msg.payload[0].includes(\"hour\")) {\n    hour = parseInt(msg.payload[0])\n} else if (x == 1 && msg.payload[0].includes(\"minute\")) {\n    minutes = parseInt(msg.payload[0])\n} else if (x == 2 && msg.payload[0].includes(\"hour\")) {\n    hour = parseInt(msg.payload[0])\n    minutes = parseInt(msg.payload[1])\n} else {\n    hour = parseInt(msg.payload[1])\n    minutes = parseInt(msg.payload[0])\n}\nvar time_remain = hour * 60 + minutes\nif (time_remain < 120 && tide_status == \"high\") {\n// Setup for 2 hours before High Tide\n    msg.brightness = 255\n    msg.color = \"green\"\n    msg.transition = 6\n    if(time_remain < 3){\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)        \n    }\n} else if (time_remain < 120 && tide_status == \"low\") {\n// Setup for 2 hours before Low Tide\n    msg.brightness = 255\n    msg.color = \"red\"\n    msg.transition = 6\n    if(time_remain < 3){\n    flow.set(\"change_time\", msg.time)\n    flow.set(\"tide_past\", tide_status)        \n    }\n} else if (time_remain > 120 && change_diff1 < 7200000 && tide_past == \"high\") {\n// Setup for 2 hours After High Tide\n    msg.brightness = 255\n    msg.color = \"green\"\n    msg.transition = 6\n} else if (time_remain > 120 && change_diff1 < 7200000 && tide_past == \"low\") {\n// Setup for 2 hours after Low Tide\n    msg.brightness = 255\n    msg.color = \"red\"\n    msg.transition = 6\n} else if (time_remain > 120 && change_diff1 > 7200000 && water_status == \"rising\") {\n// Setup for Rising Tide Between High And Low\n    msg.brightness = 255\n    msg.color = \"yellow\"\n    msg.transition = 6\n} else if (time_remain > 120 && change_diff1 > 7200000 && water_status == \"falling\") {\n// Setup for Falling Tide Between High And Low\n    msg.brightness = 255\n    msg.color = \"yellow\"\n    msg.transition = 6\n} else if (time_remain > 120 && water_status == \"falling\" ) {\n// Setup for Falling Tide Between High And Low\n    msg.brightness = 255\n    msg.color = \"yellow\"\n    msg.transition = 6\n} else if (time_remain > 120 && water_status == \"rising\") {\n// Setup for Rising Tide Between High And Low\n    msg.brightness = 255\n    msg.color = \"yellow\"\n    msg.transition = 6\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1040,"y":2020,"wires":[["06569ceaba7b0328"]]},{"id":"d177950.2a5aa68","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Woot! I believe this is working. The light lit with the appropriate color for the current tide.
I am going to monitor this throughout the tide cycle to confirm and update this.

I very much so want to follow your suggestion but I don’t currently have the knowledge to do so.
I’m reading allot and learning so much. I now know this entire topic was pretty aggressive for a newbie to attempt.

do let me know, if there are issues. please note for the system will be fully configured only after a high or low tide after the nodered is restarted. I have made the request interval 1min so that the automation would be that accurate. There can be other methods also which can use timers to reduce the scrape sensor use.

Unfortunately the light never changed colors, it remained in the same state.

I have tried it and it is working for me. I could not check with the hole pattern but in my case the color changed from yellow to red as soon as the time was less than 2 hours form the website.
Please check of the light is changing colors with this test flow.

[{"id":"76f479a0ce7f11ed","type":"inject","z":"51045e07.bbf87","name":"green","props":[{"p":"brightness","v":"255","vt":"num"},{"p":"color","v":"green","vt":"str"},{"p":"transition","v":"6","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":1490,"y":2140,"wires":[["dd6b3dcc543f4f5e"]]},{"id":"dd6b3dcc543f4f5e","type":"api-call-service","z":"51045e07.bbf87","name":"Light","server":"d177950.2a5aa68","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.wled","data":"{\"brightness\":\"{{brightness}}\",\"color_name\":\"{{color}}\",\"transition\":\"{{transition}}\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1630,"y":2120,"wires":[[]]},{"id":"7516416d82a99537","type":"inject","z":"51045e07.bbf87","name":"red","props":[{"p":"brightness","v":"255","vt":"num"},{"p":"color","v":"red","vt":"str"},{"p":"transition","v":"6","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":1490,"y":2100,"wires":[["dd6b3dcc543f4f5e"]]},{"id":"06b8b4871e65bce5","type":"inject","z":"51045e07.bbf87","name":"yellow","props":[{"p":"brightness","v":"255","vt":"num"},{"p":"color","v":"yellow","vt":"str"},{"p":"transition","v":"6","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":1490,"y":2180,"wires":[["dd6b3dcc543f4f5e"]]},{"id":"d177950.2a5aa68","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

It is working perfectly, the error was with my server. This is exactly what I was hoping to achieve. Thank you… Looks so cool dimmed on a low light in my backyard.

1 Like