Receive a Telegram notification if a light or a fan has been on for a certain amount of time

Hi there, I am new to HA and Node-RED and need some help getting a flow that will send me a notification to a Telegram Bot (which I already have set up both on the Telegram side and HA side) but I do not have an idea in how to set up the flow properly. Can I get some help on this?

Use the Node-Red Events: state node.

image

that works perfectly … what component can I use in front of this state node to simulate the on/off of the entity while I am designing my flow?

The state node does not take an input. You can toggle the entity (on/off) using home assistant

image

1 Like

For some reason I am unable to get this working properly, need some more eyes on top of it maybe I am missing something …

The above flow has two errors:

  1. The debug named Output Text does not output anything, no ideas why
  2. Even if the message says it was “success” I don’t get it on Telegram.

This is the WF JSON (I have removed sensitive information):

[
  {
    "id": "acc66eae0bd38f04",
    "type": "tab",
    "label": "Lights On",
    "disabled": false,
    "info": "",
    "env": [

    ]
  },
  {
    "id": "53068e834c06c590",
    "type": "server-state-changed",
    "z": "acc66eae0bd38f04",
    "name": "Office Fan On",
    "server": "e593dd3.052432",
    "version": 4,
    "exposeToHomeAssistant": false,
    "haConfig": [
      {
        "property": "name",
        "value": ""
      },
      {
        "property": "icon",
        "value": ""
      }
    ],
    "entityidfilter": "fan.office_switch",
    "entityidfiltertype": "exact",
    "outputinitially": false,
    "state_type": "str",
    "haltifstate": "on",
    "halt_if_type": "str",
    "halt_if_compare": "is",
    "outputs": 2,
    "output_only_on_state_change": true,
    "for": "2",
    "forType": "num",
    "forUnits": "seconds",
    "ignorePrevStateNull": false,
    "ignorePrevStateUnknown": false,
    "ignorePrevStateUnavailable": false,
    "ignoreCurrentStateUnknown": false,
    "ignoreCurrentStateUnavailable": false,
    "outputProperties": [
      {
        "property": "payload",
        "propertyType": "msg",
        "value": "",
        "valueType": "eventData"
      }
    ],
    "x": 110,
    "y": 220,
    "wires": [
      [
        "20ef09168211f89b"
      ],
      [

      ]
    ]
  },
  {
    "id": "20ef09168211f89b",
    "type": "template",
    "z": "acc66eae0bd38f04",
    "name": "Get Friendly Name",
    "field": "payload",
    "fieldType": "msg",
    "format": "handlebars",
    "syntax": "mustache",
    "template": "{{payload.new_state.attributes.friendly_name}}",
    "output": "str",
    "x": 330,
    "y": 220,
    "wires": [
      [
        "45539f102a173ff4",
        "905010c14ae31dc5",
        "9e2c2f4782d6b56b"
      ]
    ]
  },
  {
    "id": "9e2c2f4782d6b56b",
    "type": "chatbot-conversation",
    "z": "acc66eae0bd38f04",
    "name": "",
    "botDevelopment": "780d533fd55e876e",
    "botProduction": "780d533fd55e876e",
    "chatId": "1063333784",
    "userId": "",
    "transport": "telegram",
    "x": 630,
    "y": 320,
    "wires": [
      [
        "4d13621c211594c8"
      ]
    ]
  },
  {
    "id": "bce12a94f8d109d8",
    "type": "debug",
    "z": "acc66eae0bd38f04",
    "name": "Message Success",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "true",
    "targetType": "full",
    "statusVal": "",
    "statusType": "auto",
    "x": 1050,
    "y": 280,
    "wires": [

    ]
  },
  {
    "id": "45539f102a173ff4",
    "type": "debug",
    "z": "acc66eae0bd38f04",
    "name": "Friendly Name",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 560,
    "y": 160,
    "wires": [

    ]
  },
  {
    "id": "31e053355ae220e6",
    "type": "debug",
    "z": "acc66eae0bd38f04",
    "name": "Message Failed",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 1040,
    "y": 360,
    "wires": [

    ]
  },
  {
    "id": "4d13621c211594c8",
    "type": "chatbot-telegram-send",
    "z": "acc66eae0bd38f04",
    "bot": "780d533fd55e876e",
    "botProduction": "780d533fd55e876e",
    "track": false,
    "passThrough": true,
    "errorOutput": true,
    "outputs": 2,
    "x": 830,
    "y": 320,
    "wires": [
      [
        "bce12a94f8d109d8"
      ],
      [
        "31e053355ae220e6"
      ]
    ]
  },
  {
    "id": "1f6e139f0eee4fcb",
    "type": "debug",
    "z": "acc66eae0bd38f04",
    "name": "Output Text",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 710,
    "y": 220,
    "wires": [

    ]
  },
  {
    "id": "905010c14ae31dc5",
    "type": "chatbot-message",
    "z": "acc66eae0bd38f04",
    "name": "",
    "message": [
      {
        "message": "{{payload}} has been on for more than 5 minutes!"
      }
    ],
    "language": "none",
    "x": 530,
    "y": 220,
    "wires": [
      [
        "1f6e139f0eee4fcb",
        "9e2c2f4782d6b56b"
      ]
    ]
  },
  {
    "id": "e593dd3.052432",
    "type": "server",
    "name": "Home Assistant",
    "addon": true
  },
  {
    "id": "780d533fd55e876e",
    "type": "chatbot-telegram-node",
    "botname": "RPHomeIntegrationBot",
    "usernames": "",
    "polling": "1000",
    "store": "",
    "log": "",
    "debug": true,
    "skipMediaFiles": false,
    "webHook": "",
    "connectMode": "polling",
    "storeMessages": true,
    "enableMissionControl": false,
    "inspectMessages": true,
    "chatbotId": ""
  }
]

What I am missing here?

I don’t use Telegram so I can’t help debug your code.