Take a look at this
[{"id":"560d1b0b.9538e4","type":"cron","z":"b4f13d0.1052fc","name":"Every hour[22:00 to 6:00]","crontab":"01 22-23,0-6 * * *","x":150,"y":540,"wires":[["e65d3982.fc5e98"]]},{"id":"e65d3982.fc5e98","type":"api-current-state","z":"b4f13d0.1052fc","name":"checkLoungeSensor","server":"d5ce5cec.92bc8","halt_if":"on","override_topic":true,"override_payload":true,"entity_id":"binary_sensor.0x00158d0001f9b9af_occupancy","x":400,"y":540,"wires":[["d6aea734.352bd8"]]},{"id":"4c016abc.77d9d4","type":"inject","z":"b4f13d0.1052fc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":600,"wires":[["e65d3982.fc5e98"]]},{"id":"99db09e1.ecabe8","type":"comment","z":"b4f13d0.1052fc","name":"Turn off lounge devices [WIP]","info":"","x":140,"y":500,"wires":[]},{"id":"d6aea734.352bd8","type":"function","z":"b4f13d0.1052fc","name":"addSeconds","func":"dateSinceLastChanged = Date.parse(msg.data.last_changed);\ncurrentDate = (new Date).getTime();\nsecondsSinceLastChange = Math.round((currentDate - dateSinceLastChanged) / 1000);\nmsg['secondsSinceLastChange'] = secondsSinceLastChange;\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":540,"wires":[["a6e2fa4c.a97ef8"]]},{"id":"a6e2fa4c.a97ef8","type":"switch","z":"b4f13d0.1052fc","name":"passOnlyAfter45minutes","property":"secondsSinceLastChange","propertyType":"msg","rules":[{"t":"gte","v":"2700","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":810,"y":540,"wires":[["d5900ef1.b1ea6"]]},{"id":"d5900ef1.b1ea6","type":"api-current-state","z":"b4f13d0.1052fc","name":"checkKodiLounge","server":"d5ce5cec.92bc8","halt_if":"playing","override_topic":true,"override_payload":true,"entity_id":"media_player.kodi_lounge","x":1050,"y":540,"wires":[["8a5e3223.2d92a"]]},{"id":"8a5e3223.2d92a","type":"change","z":"b4f13d0.1052fc","name":"delEntity_Id","rules":[{"t":"delete","p":"data.entity_id","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1230,"y":540,"wires":[["e622dd7.8143b2"]]},{"id":"e622dd7.8143b2","type":"api-current-state","z":"b4f13d0.1052fc","name":"checkLoungeTV","server":"d5ce5cec.92bc8","halt_if":"on","override_topic":true,"override_payload":true,"entity_id":"media_player.lounge_tv","x":1400,"y":540,"wires":[["d27438b8.6071d8"]]},{"id":"d27438b8.6071d8","type":"api-call-service","z":"b4f13d0.1052fc","name":"turnOffLoungeDevices","server":"d5ce5cec.92bc8","service_domain":"script","service":"turn_on","data":"{\"entity_id\":\"script.turn_lounge_off\"}","mergecontext":"","x":1620,"y":540,"wires":[[]]},{"id":"d5ce5cec.92bc8","type":"server","z":"","name":"Home Assistant","url":"https://localhost","pass":"password"}]
This checks every hour for lounge activity to turn off some lights and the TV, it will parse the msg.data.last_changed field, which usually comes in Iso8601, transforms into seconds. Then there is a switch that will only let if there has been no motion for 45 minutes at least. The timestamp-date transformation is a function, i don’t know if there is a specific node that can do that time change to seconds.