Inspiration in what is possible

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
zicht
Posts: 300
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Inspiration in what is possible

Post by zicht »

Hi,

Sometimes the question is posted "what (project) have you put together with domoticz" or questions seeking some inspiration.
In this post i will summarize what i have created as ideas for others.

(@mods : move this post if you think is best fitting on another threat, just posted it here because all is based on lua)

When i started, i knew nothing, all is learned on the job. I had no scripting skills at all and no knowledge of any form of automation.

LUA
First of all i am working in lua only (no dz events) because thats how it started back then, and it took a lot of time to learn and understand.
So i kept with what i learned and never ported to dz events.
I learned the hard way in lua that you always have to check current value before to set a new value to avoid loops ending in crashing domoticz , or massive domoticz slow down due to constantly repeated actions.
And in if-then constructions for devicechanged, also check always agains a value, just to exclude nil values that can throw a lot of errors in a short time.
I have roughly 10 device scripts end 20 time based script. I have created a separate function file thats loaded in each script and is my storage place for all functions in lua (reuse what's possible in all scripts)

RPI/X86
For stability reasons i transferred in 2018 most to windows on an old laptop : I was tired of SD cards getting corrupted, and this was closest to my skill set. (This is an old small laptop using not too much energy, i mounted a ssd drive) I never had any problems any more. Domoticz runs on Windows very stable in my opinion. (But i've learned that all the same things are possible on RPI also with ssd and so. Thinking not to change a winning team i keep what ive got until hardware breaks. I have already an RPI running as testing platform.) I am always one version behind, and check forum before updating production env. If things are reported i wait till things are solved. Lately i never had to wait but i'll keep the habit

Open Hardware monitor
I use open hardware to monitor CPU temp, CPU %, HD Temp, HD % usage, Mem % usage.
CPU % was really helpfull to keep domoticz up to speed. HD usage is handy to do a cleanup at a certain point, i have plenty of discspace, it it helps in performance.

Python libs
I use a lot of python scripts (not plugins) with the Domoticz JSON api to get values in sensors. I try to avoid plugins, as over the years i experienced them going out of support after some time. I use maintained python libs, try to understand them and add some domoticz interaction, Over the time i get better at this, but in reality python is beyond my skills. I just manage to make a json call with values to domoticz.(Sometimes with a lot of help on Python forums)
This gives me a good feeling of being in controll. Off course the always changing api's are a pain in the *** because then the libs needs adjustment. Sometimes i can do this myself and sometimes i have to wait or find a new lib.

Windows schedular
I have set up windows scheduler with batch files to get external data (HTML/JSON) into text files. I recently made this move as this is running in a separate process thus speeding up domoticz a lot. The text files are written to a ram drive --> Much faster access from domoticz & cleared on reboot. Domoticz is now making no calls, just reads the files (disk.IO)

Scraping
I use : - chrome canary to scrape &
- curl.exe for windows (not the default thats in windows at the moment!) to plain read stuff.
Till now i was able to get anything i wanted.

Nature monitoring :
Dutch RIVM has a big set of usable data below what i use from them :
  • NO, NO2, Pm10, PM2.5, O3, SO2, C7H8, C8H10, LKI --> If one of them get at an alarm level the inhome vent system shuts down.
    Seawater temperature --> No interaction just nice to now in summer when going to the beach
    Sea wave size --> No interaction, nice to know when going out (rental) boating.
    River water levels --> Telegram message when rising above x level nearby like a "floating alert"
Tsunami : Monitoring Pacific & US, not relevant yet in my region, but nice to know
Earthquakes : Monitoring Local and world, relevant and interesting to monitor
Lightning/ thunderstorms: gives telegram message : useful to disconnect antenna when closing to my home.
Rain & wind & outside temperature : Rain values --> used to close external window shutters
Outside Temperature : used to adjust air-conditioning & stop inhome ventilation if needed. Also used to set up heating parameters in winter. Also closing the curtains and outside window shutters when sunny and hot outside.

Grip level monitoring : Dutch C2000 government alarm levels, used to stop vent when a building nearby is on fire (or other triggers) and when really close the outside windows shutters are closed
NL alert & Amber-Alert : Also nice to know. When nearby generates a telegram message.

Garbage calendar : display on custom page a message in the morning so i dont forget

Whether alerts from https://www.meteoalarm.org/nl/live/ : Notification for today and tomorrow on telegram + close outside window shutters if needed ( time frames are reported on the alerts.)

Energy monitoring : Telegram gives an alert on things strange/ out of range values. Also some custom sensors to be able to check the energy bill more precisely and to reduce costs

Solar panel monitoring as input for Energy monitoring & to activate things on sunny moments ( save energy)

IR blaster so anything that used IR can be managed by domoticz ( also as backup for airco, tv and local in room heater)

Water usage and warm water* usage : to be able to check the energy bill more precisely and to reduce costs, also leakage detection.

Ventilation as you can read its managed by a lot, also by indoor air quality, temp and humidity. I have a selector switch where i can set a focus.

light bulbs color and light intensity is managed on a set of parameters like present light (lux), time of day, movement and other triggers. It is completely automated and can be adjusted with physic wired and wireless switches (zigbee) ánd colors intensity. Sometimes also as a signal to a certain situation, like alarm settings, presence detection or some exception. In general more movement = intenser light.

I have energy measuring smart plugs on :
  • Television/ audio set
    Washing machine Gives message when finished based on Elektra use, shuts off when current > offset (fire prevention)
    Drying machine Gives message when finished based on Elektra use, shuts off when current > offset (fire prevention)
    Dishwashing machine Gives message when finished based on Elektra use, shuts off when current > offset (fire prevention)
    Fridge Gives message when not closed based on Elektra use.
    central heating system used for warm water usage detection together with water meter. Heating and warm water are combined, but each has a different power consumption profile. That's how i can distinguish them.
Think of it: many equipment have powerconsumption signatures for different usage. I am still adding things based on this.

Internet :
Disables external loading scripts when I-net connection problem occurs as i load a bunch of data from internet (pinging first hop outside provider network) & notify on telegram when back normal.
Also logging speed test download and upload every hour.

Traffic (Waze :
Morning : Home-work Afternoon : Work-Home (travel time & distance)
When not normal at 7h00 and at 16h00 it sends a message to telegram.

Air-conditioning :
fully controllable in domoticz, but scripts run this fully automatic based on measured values from in home sensors (=not airco sensors). Heating, cooling, drying as efficient as possible taking energy usage into account , e.g. airco on when hot and sun is shining, but pause when its getting cloudy for >5 min. (Not stopping as many start stop reduce lifespan of mechanical parts, i set the wished temp close to current temp, result = airco using less energy.)
Airco is fully automated, cooling and heating. This takes solar energie into account, for uptimum use of solar energy. I never adjust manual ( not needed) Works in conjunction with curtain, central heating, radiator vents, solar, external and internal temperature sensors, all on all floors. If heating takes to long then downstairs an extra elektric heater will jump in to speedup ( during solar energy)

Movement & lightning :
I have many movement sensors (also equipped with temp and light sensors)
These are used for fully automated lamps.
I have a custom page in domoticz showing on a plan where is movement in a room and what is the room temperature.
Smart lighting is not only based on movement but also on energy usage of earlier mentioned equipment.
I cook electric --> energy usage is setting cooking vent, central vent and kitchen lighting
Door opening sensors --> special light settings inside and outside, also stops heating when not closed in time or gives an alert when leaving

Bathroom :
Detecting when shower is in use with movement, water and energy usage. When showering > 5 min lights will sign. When waking up & movement max lights in bathroom for shaving. If we push a button a special dimmed light scene is activated.

Toilet :
Toilet in use >3 min. then vent on

Safety :
Smoke detection : cutting of electricity where needed, water off and external window shutters closed (keep oxygen out) , all vent off, all sealing lights dimmed on & floor light max ( below smoke, as smoke rises)

Sounds by domoticz :
I announce important messages (with Text to speech) on each floor. Like things are ready or an exception occurred.

Scraping :
Scraping latest news headlines.
Scraping missed and wanted persons within 50 km radius

15 Scenes for recurrent handlings
Outdoor scene, bases on movement, party etc
Alarm Scene
Movie scene in 2 rooms
Audio scene in all rooms, with audio following the movement --> Nice playing spotify and music is where you are.
....

AV receiver settings
All adjusted based on who is in tha house and what is happening ( muzic, movie, party, streaming)
Took a while to see patterns and most used settings for those, but its almost running fully controlled by domoticz

Planes:
Using ADSB to monitor nearby airplanes distance, alt, speed, type, call sign ( collect data if needed to be able to file a report (later on) if i want to, just get only data based on criteria i've set)

iRobot :
Cleaning is started by domoticz when not at home, directed to spaces based on the movement sensor detections. (Where nobody has been , no cleaning needed.)

Curtains and outdoor window shutters managed by all kind of parameters to close/ open. Even if i forget to close a windows, one of the benefits is the rain is never coming inside ... Curtains are in summer closed based on lux and temp preventing sun to heatup the room on sunny side of my home. In winter they are closed nd opened based on outside temp, heating on or off and many more things.

Radiator ventilators are in summer used in conjunction with the airco to get air circulation when airco is cooling (+ Radiator is also cooling airflow a bit) and the airflow from airco is more diffused. In winter the radiator vents are used to spread the heat more and faster true the room speeding up the heating (10 min less heating needed to get the set temperature)

Local ground temperature --> Gardena used, give message on low temp usable info for driving
Local ground moisture --> in conjunction with wether conditions and temperature : watering the garden

Door locks --> Doors locked when away, open when arriving home, unlatch the door when i arrive by car, open garage door when i arrive at a bike.

Face recognition & presence detection --> I use an old android phone, catch recognition notifications from cams and send to domoticz with Tasker (no APi). This android phone is located next to the pc ( I never take it with me) Face recognition is used to arm and disarm security. Works pretty well, just need a backup in case something's not working well : I use telegrambot as backup to be able to interact.
Also send a message with picture to telegram (high-res) when not home and not recognised person enters! Till today never had a picture and hope it keeps that way

Phone monitoring Tasker sends some parameters to domoticz based on certain events. This way the home is warm when arriving, lights are adjusted and more.

BT & network monitoring & presence detection ALL BT mac and network Mac are captured and analyzed, (all beacons) --> used for present and trespassing detection. Together with face recognition & face profile storage, I have quite a profile now on any one moving on my property.

Security
I have also implemented some countermeasures when some tries to access my home (without permission) or when being unknown to the system, including a phone call phoning out ( using TTS to make the message). The kids feel very secure because of this when being home alone, they have also a panic button.
I have build a sensitivity selector for the alarm threshold. Sometimes when very windy it can trigger some movement sensors, they can be excluded by a simple tap. The selectorswitch sets 4 levels of detection with different values for x time movement when "Armed away" or "Armed home". Opening doors triggers always immediatly the security system resulting in some actions.
The security system has a special mode when face-recognised persons are detected, with different actions based on time and the person being recgnised. If enabled even with custom personalised greatings via TTS. ( it scares people, so its mostly disabled)

Google agenda & outlook agenda interaction with tablet on the wall for appointments and notes I made.
Telegram bot i can adjust anything by telegram, again, if i need to adjust something's going wrong and i will take a look into how to avoid later on. So telegram is used to inform silently or with notification and telegram can be used to interact.
RPI as smart speaker I have a living room RPI with a speaker mounted, with text to speech i have it announcing what's going on or is detected. I am trying to get it to listen also like a smart speaker but have had no luck at the moment.

Script Timing protection I measure running time of each script and have set some general tressholds --> also a total of all time- and device- based scripts. This way if something is causing a delay, let say a sensor is behaving strange, i made a typo, something wrong on an external python script, it will be easy to find the cullprit. Saved me a lot of time in error tracking. Timing is a thingy especialy if you want to send/ receive things from/to internet. (This can make domoticz very slow, but there are ways to avoid that)

Inter(net) connectivity I have nothing sending/ receiving data from internet directly from within domoticz. As domoticz waits to finish the call, your lights and device values will wait too, i found it annoying back in 2020 and made batch scripts, called by windows schedular saving data into a text file on a ram drive. Once a day the ram drive is flushed. This way domoticz never has to wait. Took a while to make it usable but runs smooth now and domoticz is lighting fast. (yes you can't run tasks in schedular every 10 sec but if you are creative in the trigger settings: by default only once a minute is possible on windows schedular, so make a trigger with seconds delay on top of the initial trigger and you can run every 10 sec..)

Network
All devices are on a VLAN and i have a pFsense firewall running with strict rules how things can communicate to each other and/or to the internet. Never disclose anything to the internet directly, In 2018 i have been hacked due to crappy firmware of a device connected to domoticz. That was a big learning lesson.
Now i only work true reversed proxy (also on LAN), external access only by VPN, i've altered the index page with 2 lines, to set a super cookie, and with PHP a Browser ID, local ip, wan IP and country location are stored in domoticz database on logon. (If not originating from my country you will be redirected to a decoy site, also when not accesing via the reverse proxy you get the decoy, nothing can directly 1:1 communicate on the LAN with domoticz website.

Wall mounted Tablet
I have a tablet on the wall in a central place (to display what srelevant at that moment with a custom template)
I dont use the tablet to adjust things, if i need to adjust something in domoticz, my script is not working well, so i'll adjust that rather.
(BUT : i'll keep normal use like light switches to, just for when people visiting or something's broken. You can always fall back to the original interaction with the lamp or device.)

The tablet shows a dynamic filled template with for us most usable date from domoticz.
That pages shows only what's relevant at that specific moment. Fixed on the site is who's present and energy consumption.
So it could display a domoticz message, NL alert, breaking news, travel time and so on.... what ever is relevant at the time you look at it. No direct sensors, and its lean and clean.
When the front door opens it shows a warning to strangers (with an attention for facerecognition and BT/Wifi beacon scanning)
When domotics is "Armed home" or "Armed away" the tablet shows the security panel on the right side of the page, making it easy to disarm.

Domoticz has also another template website, where anyone can type a message that can be send to broadcast with TTS to a selectable device.
I can even start casting a youtube movie to a television or another casting receiver from this site.

Feel and effect
Probably i forgot some, just when things fail i remember how many i have done in domoticz. (My goals is not to adjust anything by hand)
For most things i have also running monitoring for when something fails or when i forget something (e.g. to turn something off)
So anything i could think of is managed by domoticz and automated. ( suggestions ?)
The energy bill is reduced with about 15-25% by smart mangement of gas and elekticity use.
The water measurement made me discover a small leak about 3-4 liter a day. I would have never discoverd this without domoticz (or when it was to late and had done a lot of damage)

WAF
Biggest problem is the Wife Acceptance Factor ... But if its easy to use and feels natural it helps a lot. So i do not trial and error in working env. but test, test and test again before implementing.

Conclusion
Anything is possible, your imagination/creativity is the limit.
Domoticz is very flexible and you can interact with almost anything ...

:arrow: p.s. This year is my 9-year anniversary on domoticz 8-) ( the first period i was not on the forum)

<edit : many typo's and add things i forgot to mention>
Last edited by zicht on Monday 21 October 2024 17:52, edited 22 times in total.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
User avatar
waltervl
Posts: 6689
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Inspiration in what is possible

Post by waltervl »

Thanks for showing all the functionality you have implemented with Domoticz. I have move the topic to the "Show your projects" subforum
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
zicht
Posts: 300
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Inspiration in what is possible

Post by zicht »

waltervl wrote: Saturday 12 October 2024 14:17 Thanks for showing all the functionality you have implemented with Domoticz. I have move the topic to the "Show your projects" subforum
Thanks, hope its a good promotion on the possibilities of domoticz :D
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
Kedi
Posts: 595
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Inspiration in what is possible

Post by Kedi »

Nice..... :D Post some of those scripts here for the community with some explanation for somebody who want to use those.

How do you handle things when Internet is down for some days?
How do you handle things when Main Power is down for some hours?

Because that is what I learned to investigate and handle by experiance.
The more you get automated, the more you have to think about those things.

I learned that you have to have an UPS not only for the raspberry (or what ever system) but also a UPS for my rollershutters.
Otherwise I could not get out or in my house when the shutters are closed in case of main power down.
That takes a lot of thinking for all kind of case of 'what if'
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
kiddigital
Posts: 447
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Inspiration in what is possible

Post by kiddigital »

Impressive @zicht
Great to see how Domoticz helps making life a little nicer

On security, considered using Domoticz 2 Factor Authentication?
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
zicht
Posts: 300
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Inspiration in what is possible

Post by zicht »

Kedi wrote: Sunday 13 October 2024 8:38 Nice..... :D Post some of those scripts here for the community with some explanation for somebody who want to use those.

How do you handle things when Internet is down for some days?
How do you handle things when Main Power is down for some hours?
Thanks
Good questions, fortunaly i have no outage for days of anythings. Infra is pretty decent out here.
biggest win was on this one :

Code: Select all

package.path = package.path .. ';' .. 'functions.lua;'
local my = require ("functions")
It contains all reusable functions and is loaded BEFORE anything in the script at the first 2 lines (before : "commandArray = {}" )
Now i can call all the functions from any script without doing anything more, like its part of the script running. At this moment it contains 6400 lines of code

1.
I have in each script that depents on internet a check at the beginning of the script to determen if internet is down.

Code: Select all

commandArray = {} if otherdevices["Hoofdschakelaar"]=="On" then
script things done
end
If its down, all dependencies in the script are skipped --> So no errors or time consuming waiting if inet is down.
On hardware side i have it all made so that its also usable by manual switching, activating etc.
So nothing is 100% depending on scripts only, you can allways override of do manual actions. (learned this backup is needed the hard way)

-->second benefit of this is that "stangers" visiting you are not completely lost in your home, they can use things as if the are at home

2.
Outage of Main power is at this moment not likely.
I have a small UPS for domoticz and modem (glasfiber) that can run upto 2 hours and then a controlled shutdown will follow.
NO ups at windowshutters, thats ok for now, but if outage will be frequent then for sure it needs a UPS
(I can manual start things up on solar panels after taking them off grid by an emergency circuit, probably i will use it for the fridge and not for domoticz :) )

(Be aware that even glassfiber will eventualy go down as the ISP "boxes" out of your house also have limited backup power, and a grid outage is bigger than your home, so they will go down...)

For security : my modem is behind a smart switch. So if inet is down for over 60 minutes, is goes off --> thus saving ups power.
I also monitor logins on my systems by reading the log lines --> more than 5 login errors in 3 minutes kills power on the modem.
It comes back after X time or upon my request by telegram --> but when >20 minutes down i will get a new WAN-IP from my ISP, so i needed also a mechanisme on telegram to know my new WAN-IP

Since i have no open ports other than for VPN : this had not occurred since then.
But when domoticz was on inet back then, there where many attempts killed by this system

I will post some on request, but i am not a coder, just trial and error programming. (but works...)
The thing is i really should start over again, with the knowledge of today i can make things more "nice" code wise. Lack of time....
Main goal by my overview was to show people anything is possible, you immagination (and money) are the only limits.

Cheers...
Last edited by zicht on Sunday 13 October 2024 18:31, edited 6 times in total.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
zicht
Posts: 300
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Inspiration in what is possible

Post by zicht »

kiddigital wrote: Sunday 13 October 2024 10:00 Impressive @zicht Image
On security, considered using Domoticz 2 Factor Authentication?
Thanks !
Yes i did think of 2FA, but i do not see the benifit when only accesible with VPN.
Below description was build before 2FA was available, and created after being hacked.
I feel pretty secure right now.
Domoticz is on a seprate vlan, equipemnt has its own vlan and uses separated WIFI.
both vlans not accesible for anyone, (building VLANS is really complicated if you are not knowing what you are doing)
with PFsense firewall the connections between vlans and inet are limited to absolute minimum.

See previous post how i handle login errors with modem switching off. (windows has no fail2ban)
p.s Last year i was (fysical) not very healthy so i was limeted in movement and my home automation was really helpfull....
I totaly underestimated the IR blasters, i included them for fun, but being ill i did not have to look for remotes every time, and its usable cross floor without need to move around. (Or the announcement of washing machine/dryer being ready, preventing unneeded stairs...)
Healthcare should invest more in home automation in my opinion.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
zicht
Posts: 300
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Inspiration in what is possible

Post by zicht »

<edit> deleted, below is a better discription (this post was just a list of function names)
Last edited by zicht on Monday 27 October 2025 8:06, edited 1 time in total.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
zicht
Posts: 300
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Inspiration in what is possible

Post by zicht »

as some asked a while ago for more details, i asked AI to make an extract....
I know it should be in englisch but i think most of it is good understanable. Every time i asked englisch it switched to ducth, prob because its the language i used in the scripts. Sorry for that.

--

# 📦 Domoticz Script Overview – Flowcharts & Logic

## 📁 script_device_100_alg_optimized.txt — General Behavior & Energy Management
[Trigger: devicechanged]
- Alarm_Master == On → Start alarm light + sound
- Signal triggers (Slow-Woop, Alarm, Happy) → Cast audio via HTTP
- Ampere > 35 + cooldown → Switch off TAPO devices
- Motion sensors → Switch on TAPO devices
- Time + attic TV → Switch off TAPO devices
- Back door + motion → Activate fountain
- Front door / Garage / Back door → Start batch notifications + write to queue
- Hue smart plug VPN > 2h off → Switch on
- nb lamp on too long → Switch off
- Security Panel status → Update iframe

## 📁 script_device_110_licht_nieuw.txt — Lighting Control & Hue Dimmer Switches
[Trigger: devicechanged]
- Main switch == Off → Turn everything off + temporarily enable base lighting
- Cleaning On/Off → Switch relevant lights on/off
- Lux values + time → Switch SunUp on/off
- Recent doorbell → Flash lights + notification
- Motion sensors → LightExtraOn()
- Hue Sync → Start/stop via exe
- Hue dimmer switch 1 to 6 → Color cycle, brightness, reset, presets

## 📁 script_device_111_tellers_tv_yamaha.txt — Counters & Yamaha Automation
[Trigger: devicechanged]
- Update counters for door, motion, fans
- Calculate total motion → Update variable + SetValue_IDX
- Audio_Master == On → Yamaha/TV/Chromecast logic

## 📁 script_device_190_masterswitch.txt — Master Switches & Template Management
[Trigger: devicechanged]
- Rename_force() for sites
- subMasters dependencies → Switch off related devices
- ScheduledTasks per master → Enable/disable via PowerShell
- Alarm_Master off → Disable AutoArm, timer, bells
- Nuki lock off → Disable door motors + enable Nprot/Gprot
- Telegram_Master off → Disable Tasker subMaster

## 📁 script_device_120_Roomba.txt — Roomba Control
[Trigger: devicechanged]
- Command Start/Stop/Dock → curl API call
- Parse last command → Extract JSON fields

## 📁 script_device_123_gordijnen_airco.txt — Curtain Logic & Temperature Control
[Trigger: devicechanged]
- trigger_ok + cooldown → Filter irrelevant triggers
- SunlightHigh conditions → Switch SunlightHigh on/off
- HeatProtocol + temperature → Close curtains partially or fully
- temp_lux1/temp_lux2 flags → Switch radiator fan on/off
- End of day → Reset curtains + radiator fan

## 📁 script_device_152_tasker.txt — Tasker Status Processing
[Trigger: TG Trigger == On]
- Read TG Text device → Decode base64 if needed
- Parse status line (1=..., 19=trigger, dev=...)
- Set variables: Bluetooth, Wifi, Location, Battery
- Calculate distance to home + speed
- Update Location device + optionally SendText

## 📁 script_device_150_telegram_poller.txt — Telegram Poller
[Trigger: TG Trigger device]
- Check: poller enabled
- Read TG Text + Sender
- Calculate checksum → skip if duplicate
- Call NLU intent handler
- Fallback to Telegrambot or SendText

## 📁 script_device_151_telegram_chatbot.txt — Chunked Telegram Sender
[Trigger: chatbot - OpenRouter Ready == On]
- Read OR_OUT_FILE
- Chunk into parts (.tg.partNNN.out.txt)
- Write manifest (.tg.ready)
- Send all parts with delay
- Cleanup old files

## 📁 script_device_140_beveiliging_laston.txt — Motion Timestamp Tracking
[Trigger: devicechanged]
- is_motion_name(device) + status == On → Update last_on[device]
- time_display(dev) → Show timestamp or fallback to lastupdate
- flush_last_on() → Write to file if changed

## 📁 script_device_170_alg_netwerkfirewall.txt — Network Status & Firewall
[Trigger: devicechanged]
- Network type switch → PowerShell: Set-NetConnectionProfile
- Number of people at home → Update uservariables
- Alarm_Master active → Alarm() + reset counters
- tvboven1/2 → tv_boven sync
- Mailbox + Front door → Mail notification + Cast
- Shutter_Choice → Shutter()
- Ventilation control → Switch fans on/off
- Ping logic → Switch P20Phone on/off
- Burze lightning → Thunderstorm alert + link

## 📁 script_device_180_input.txt — Inline Input & Uservariable Sync
[Trigger: devicechanged]
For each device (InputDevice, Wifi_MAC1, AnnualStatement…):
- Check: uservariable exists? → Add if needed
- Check: first use ("Hello World")? → Init HTML + set var
- Check: devicechanged? → Update var + HTML
- Special logic (InputDevice): write message to dialogboxI.txt

---

## 🔌 TAPO Energy (script_time_151_1N_tapo_fast.txt)
[Main switch + TAPO_Master = On] → per device:
- Decode JSON (_current + _mnt)
- Update usageW + todayKWh → UpdateCounter()
- Update YTD → UpdateYTD()
- Sync On/Off status
- Washing machine/Dryer: detect nearly finished

## 🧹 Roomba (script_time_141_Roomba_fast.txt)
[Main switch + Roomba_Master = On] → status check:
- Command = Busy → Start Roomba
- Command ≠ Busy → Stop Roomba
- Parse JSON files → audio, battery, phase, bin, lastCommand
- Detect region → Update Roomba region
- Detect stuck/full/dock → Update Command
- Update IDX with status

## 📡 Bluetooth MAC (script_time_171_BT_Mac.txt)
Every minute:
- Read BT_disc.txt + BT_list.txt
- Compare MAC + description
- New MAC → SendText + WriteToFile
- Match with BT_MAC1/2/3 → Switch device on
- TDiff > 500s → Switch device off

## 🌐 ARP/MAC/IP (script_time_170_mac_en_Ip_en_arp_fast.txt)
[ARP file changed] → Parse ARP:
- Detect unknown MAC/IP → SendText + WriteToFile
- Doorbell active → Search known MAC → SendText who’s home
- Periodic → MacFind() + MacFindExtra()
- Car/Motor active → MacFind(true)
- Internet active → IPlog() + CheckIPGSM()

---

## 🧠 General + Waste (script_time_100_alg_incl_afval.txt)
Every minute:
- Front door check → WarningOFF.bat
- Smoke alarm → Slow-Woop + Group:All
- Alarm → Signal + Group:Alarm
- Firewall timeout → Switch off/on
- Visibility check → dialog_window
- Motion stuck → Reset devices
- Lighting control → Group:temporary living room on
- Shutter(), HomeAway(), Ventilation()
- Thunderstorm → Update IDX + SendText
- Water usage → Calculate day/YTD/prediction
- Fridge too warm → SendText
- Waste.txt → Parse reminder

## 💡 Light Timer (script_time_120_licht_timer.txt)
Every minute:
- 10:00 → Reset Hue color
- 01:00 → Outdoor lights on
- Sunrise+90 → Living room off
- Sunset → Living room on
- 00:01 → Living room off
- Outdoor lights off after sunrise+30
- 01/09/13h → Everything off
- checklamptime() → Reset lights based on motion + lux
- MotionT counters → -1 per 60s

## 🛰️ Terrarium (script_time_110_terrarium.txt)
Every 5 minutes:
- PREDAWN → amber fade
- DUSK → amber fade
- MOON → blue fade
- DAY → color curve + sway + cloud bump
- Thunder → white flash during lightning
- Smart suppression → skip OpenURL if no change

## 📊 Weather + Air Quality (script_time_143_weervoorspelling.txt)
Every 5 minutes:
- Reset min/max per day/month/year
- Parse moon.txt → HTML render
- Parse meteoalarm → Start task if needed
- Parse devices → Temperature, humidity, pressure
- Update forecast + UV + Rain radar

## 📰 News + Speedtest (script_time_144_nu_en_ispeed.txt)
Every 4 minutes:
- Parse nu.txt → Filter headlines
- Update News I/II → UpdateDevice
- NL-Alert override → dialog_news
Every 50 minutes:
- Parse speedtest.txt → latency, jitter, download, upload
- Update IDX with values

## 📅 Gcalendar (script_time_150_gcal_STANDALONE_v3.txt)
Every minute:
- Parse ICS → DTSTART, DTEND, RRULE
- Filter on 5-day window
- Sort by start time
- UpdateDevice → Gcalendar + upcoming
- WriteToFile → dialogboxtop.txt

---

## 🚨 NL-Alert (script_time_162_NL_Alert.txt)
Every 14 minutes:
- Parse NLAlert.txt → Check for new title
- UpdateDevice + SendText
- Parse NLAlert_heelnl.txt → Extract latest + oldest
- Update IDX with summary

## 🌍 Earthquake + Tsunami (script_time_163_Earthqtest_world_Nl_tsunami.txt)

Earthquake + Tsunami (script_time_163_Earthqtest_world_Nl_tsunami.txt)
Every 11 minutes:
- Parse EQ_world.txt → Extract ID, magnitude, depth, location
- Calculate distance → apply color coding
- UpdateDevice + SendText
Every 3 minutes:
- Parse tsunami.txt → status + location
- Parse Pacific + US feeds → Update IDX

## 🛰️ ADS-B + DMR (script_time_180_ADSB_DMR.txt)
Every minute:
- Parse adsb.txt → aircraft data
- Calculate distance + altitude → Pythagoras
- Detect LIFE/POL → color + alert
- UpdateDevice when nearby
- Parse DMR_DUAL.txt → BER/VERL color coding
- UpdateDevice on recent call

## 🧹 Log Cleanup (script_time_190_deletlog.txt)
Daily at 00:27 → delete_short_log() for text sensors
Every 2 days at 12:02 → motion, news, p2000
Every 3 days at 18:02 → caller ID, priority
Weekly on Sunday at 23:03 → lifeline, knmr

## 🚀 Telegram Flush (script_time_196_perf_tg_flush.txt)
Every minute:
- PERF_TG_Flush(10) → send max 10 messages
- Log number of messages sent

## 🧪 Test Environment (script_time_199_test.txt)
Every minute:
- Cast("It is now X o'clock") at hour change
Every 3 minutes:
- Decode deco.txt → base64 → name/IP/MAC
- Sort by IP → write to Deco_decoded.txt


Dutch :
───────────────────────────────────────────────
📦 Domoticz Script Overzicht – Flowcharts & Logica
───────────────────────────────────────────────

📁 script_device_100_alg_optimized.txt — Algemeen gedrag & energiebeheer
───────────────────────────────────────────────
[Trigger: devicechanged]
├─ Alarm_Master == On → Start alarmlicht + geluid
├─ Signaal triggers (Slow-Woop, Alarm, Happy) → Cast audio via HTTP
├─ Ampere > 35 + cooldown → Schakel TAPO apparaten uit
├─ Bewegingssensoren → Zet TAPO apparaten aan
├─ Tijdstip + tv zolder → Zet TAPO apparaten uit
├─ Achterdeur + beweging → Activeer fontijn
├─ Voordeur / Garage / Achterdeur → Start batchmeldingen + schrijf naar queue
├─ Hue smrt plug vpn > 2u uit → Zet aan
├─ nb lamp te lang aan → Zet uit
└─ Security Panel status → Update iframe

📁 script_device_110_licht_nieuw.txt — Lichtregeling & Hue dimmer switches
───────────────────────────────────────────────
[Trigger: devicechanged]
├─ Hoofdschakelaar == Off → Alles uit + tijdelijk basislicht aan
├─ Schoonmaak On/Off → Zet relevante lampen aan/uit
├─ Luxwaarden + tijd → Zet ZonOp aan/uit
├─ Deurbel recent → Knipper verlichting + melding
├─ Bewegingssensoren → LichtExtraAan()
├─ Hue Sync → Start/stop via exe
└─ Hue dimmer switch 1 t/m 6 → Kleurcyclus, helderheid, reset, presets

📁 script_device_111_tellers_tv_yamaha.txt — Tellers & Yamaha-automatisering
───────────────────────────────────────────────
[Trigger: devicechanged]
├─ Update tellers voor deur, beweging, ventilatoren
├─ Bereken totaalbeweging → Update variable + SetValue_IDX
└─ Audio_Master == On → Yamaha/TV/Chromecast logica

📁 script_device_190_masterswitch.txt — Master switches & templatebeheer
───────────────────────────────────────────────
[Trigger: devicechanged]
├─ Rename_force() voor sites
├─ subMasters afhankelijkheden → Zet gerelateerde apparaten uit
├─ ScheduledTasks per master → Enable/disable via PowerShell
├─ Alarm_Master uit → Zet AutoArm, timer, bells uit
├─ Nuki-slot uit → Zet deurmotoren uit + Nprot/Gprot aan
└─ Telegram_Master uit → Zet Tasker subMaster uit

📁 script_device_120_Roomba.txt — Roomba-bediening
───────────────────────────────────────────────
[Trigger: devicechanged]
├─ Commando Start/Stop/Dock → curl API-call
└─ Parse laatste commando → Extract JSON-velden

📁 script_device_123_gordijnen_airco.txt — Gordijnlogica & temperatuurregeling
───────────────────────────────────────────────
[Trigger: devicechanged]
├─ trigger_ok + cooldown → Filter irrelevante triggers
├─ ZonlichtHoog condities → Zet ZonlichtHoog aan/uit
├─ WarmteProtocol + temperatuur → Zet gordijnen deels of volledig dicht
├─ temp_lux1/temp_lux2 flags → Zet radiator vent aan/uit
└─ Einde van dag → Reset gordijnen + radiator vent

📁 script_device_152_tasker.txt — Tasker-statusverwerking
───────────────────────────────────────────────
[Trigger: TG Trigger == On]
├─ Lees TG Text device → Decodeer base64 indien nodig
├─ Parse statusregel (1=..., 19=trigger, dev=...)
├─ Zet variabelen: Bluetooth, Wifi, Locatie, Batterij
├─ Bereken afstand tot huis + snelheid
└─ Update Locatie device + eventueel SendText

📁 script_device_150_telegram_poller.txt — Telegram poller
───────────────────────────────────────────────
[Trigger: TG Trigger device]
├─ Check: poller enabled
├─ Lees TG Text + Sender
├─ Bereken checksum → skip als herhaling
├─ Call NLU intent handler
└─ Fallback naar Telegrambot of SendText

📁 script_device_151_telegram_chatbot.txt — Chunked Telegram sender
───────────────────────────────────────────────
[Trigger: chatbot - OpenRouter Ready == On]
├─ Lees OR_OUT_FILE
├─ Chunk in delen (.tg.partNNN.out.txt)
├─ Schrijf manifest (.tg.ready)
├─ Verstuur alle delen met delay
└─ Cleanup oude bestanden

📁 script_device_140_beveiliging_laston.txt — Motion timestamp tracking
───────────────────────────────────────────────
[Trigger: devicechanged]
├─ is_motion_name(device) + status == On → Update last_on[device]
├─ time_display(dev) → Toon timestamp of fallback naar lastupdate
└─ flush_last_on() → Schrijf naar bestand indien gewijzigd

📁 script_device_170_alg_netwerkfirewall.txt — Netwerkstatus & firewall
───────────────────────────────────────────────
[Trigger: devicechanged]
├─ Netwerk type switch → PowerShell: Set-NetConnectionProfile
├─ Aantal personen in huis → Update uservariables
├─ Alarm_Master actief → Alarm() + tellers reset
├─ tvboven1/2 → tv_boven sync
├─ Brievenbus + Voordeur → Postmelding + Cast
├─ Rolluik_Keuze → Rolluik()
├─ Ventilatie regeling → Zet ventilatoren aan/uit
├─ Ping-logica → Zet P20Phone aan/uit
└─ Burze bliksem → Onweermelding + link

📁 script_device_180_input.txt — Inline invoer & uservariable sync
───────────────────────────────────────────────
[Trigger: devicechanged]
🔁 Voor elk device (InputDevice, Wifi_MAC1, Jaarrekening…):
├─ Check: uservariable bestaat? → Voeg toe indien nodig
├─ Check: eerste gebruik ("Hello World")? → Init HTML + set var
├─ Check: devicechanged? → Update var + HTML
└─ Speciale logica (InputDevice): schrijf melding naar dialogboxI.txt

───────────────────────────────────────────────
🧠 Samenvatting
───────────────────────────────────────────────
- Alle scripts gebruiken devicechanged + allowed_devices voor CPU-efficiëntie
- Veel gebruik van TDiff(), os.clock(), en uservariables voor state-tracking
- Goede scheiding van verantwoordelijkheden per script
- Telegram-integratie is robuust en schaalbaar
- Licht, energie, beveiliging en aanwezigheid zijn goed geïntegreerd


## 🔌 TAPO Energie (script_time_151_1N_tapo_fast.txt)
```
[Hoofdschakelaar + TAPO_Master = On] → per device:
↳ Decode JSON (_current + _mnt)
↳ Update usageW + todayKWh → UpdateCounter()
↳ Update YTD → UpdateYTD()
↳ Sync On/Off status
↳ Wasmachine/Droger: detecteer bijna klaar
```

## 🧹 Roomba (script_time_141_Roomba_fast.txt)
```
[Hoofdschakelaar + Roomba_Master = On] → statuscheck:
↳ Commando = Bezig → Start Roomba
↳ Commando ≠ Bezig → Stop Roomba
↳ Parse JSON files → audio, battery, phase, bin, lastCommand
↳ Detect region → Update Roomba region
↳ Detect stuck/full/dock → Update Commando
↳ Update IDX met status
```

## 📡 Bluetooth MAC (script_time_171_BT_Mac.txt)
```
Elke minuut:
↳ Lees BT_disc.txt + BT_lijst.txt
↳ Vergelijk MAC + omschrijving
↳ Nieuwe MAC → SendText + WriteToFile
↳ Match met BT_MAC1/2/3 → Zet device aan
↳ TDiff > 500s → Zet device uit
```

## 🌐 ARP/MAC/IP (script_time_170_mac_en_Ip_en_arp_fast.txt)
```
[ARP bestand gewijzigd] → Parse ARP:
↳ Detecteer onbekende MAC/IP → SendText + WriteToFile
↳ Deurbel actief → Zoek bekende MAC → SendText wie er thuis is
↳ Periodiek → MacFind() + MacFindExtra()
↳ Auto/Motor actief → MacFind(true)
↳ Internet actief → IPlog() + CheckIPGSM()
```

---

## 🧠 Algemeen + Afval (script_time_100_alg_incl_afval.txt)
```
Elke minuut:
↳ Voordeur check → WarningOFF.bat
↳ Rookalarm → Slow-Woop + Group:Alles
↳ Alarm → Signaal + Group:Alarm
↳ Firewall timeout → Zet uit/aan
↳ Visibility check → dialoog_raam
↳ Beweging stuck → Reset devices
↳ Lichtregeling → Group:tijdelijk aan woonk
↳ Rolluik(), ThuisWeg(), Ventilatie()
↳ Onweer → Update IDX + SendText
↳ Waterverbruik → Bereken dag/YTD/voorspelling
↳ Koelkast te warm → SendText
↳ Afval.txt → Parse reminder
```

## 💡 Licht Timer (script_time_120_licht_timer.txt)
```
Elke minuut:
↳ 10:00 → Reset Hue kleur
↳ 01:00 → Buitenlampen aan
↳ Sunrise+90 → Woonkamer uit
↳ Sunset → Woonkamer aan
↳ 00:01 → Woonkamer uit
↳ Buitenlampen uit na sunrise+30
↳ 01/09/13h → Alles uit
↳ checklamptime() → Reset lampen op basis van beweging + lux
↳ BewegingT tellers → -1 per 60s
```

## 🛰️ Terrarium (script_time_110_terrarium.txt)
```
Elke 5 minuten:
↳ PREDAWN → amber fade
↳ DUSK → amber fade
↳ MOON → blauw fade
↳ DAG → kleurcurve + sway + cloud bump
↳ Thunder → wit flash bij bliksem
↳ Smart suppressie → skip OpenURL bij geen wijziging
```

## 📊 Weer + luchtkwaliteit (script_time_143_weervoorspelling.txt)
```
Elke 5 minuten:
↳ Reset min/max per dag/maand/jaar
↳ Parse moon.txt → HTML render
↳ Parse meteoalarm → Start task indien nodig
↳ Parse devices → Temperatuur, luchtvochtigheid, druk
↳ Update prognose + UV + Buienradar
```

## 📰 Nieuws + Speedtest (script_time_144_nu_en_ispeed.txt)
```
Elke 4 minuten:
↳ Parse nu.txt → Filter headlines
↳ Update Nieuws I/II → UpdateDevice
↳ NL-Alert override → dialoog_news
Elke 50 minuten:
↳ Parse speedtest.txt → latency, jitter, download, upload
↳ Update IDX met waarden
```

## 📅 Gcalendar (script_time_150_gcal_STANDALONE_v3.txt)
```
Elke minuut:
↳ Parse ICS → DTSTART, DTEND, RRULE
↳ Filter op 5 dagen window
↳ Sorteer op starttijd
↳ UpdateDevice → Gcalendar + aankomend
↳ WriteToFile → dialogboxtop.txt
```

---

## 🚨 NL-Alert (script_time_162_NL_Alert.txt)
```
Elke 14 minuten:
↳ Parse NLAlert.txt → Check op nieuwe titel
↳ UpdateDevice + SendText
↳ Parse NLAlert_heelnl.txt → Extract latest + oldest
↳ Update IDX met samenvatting
```

## 🌍 Earthquake + Tsunami (script_time_163_Earthqtest_world_Nl_tsunami.txt)
```
Elke 11 minuten:
↳ Parse EQ_world.txt → Extract ID, mag, depth, locatie
↳ Bereken afstand → kleurcodering
↳ UpdateDevice + SendText
Elke 3 minuten:
↳ Parse tsunami.txt → status + locatie
↳ Parse Pacific + US feeds → Update IDX
```

## 🛰️ ADS-B + DMR (script_time_180_ADSB_DMR.txt)
```
Elke minuut:
↳ Parse adsb.txt → vliegtuigdata
↳ Bereken afstand + hoogte → Pythagoras
↳ Detecteer LIFE/POL → kleur + alert
↳ UpdateDevice bij dichtbij
↳ Parse DMR_DUAL.txt → BER/VERL kleurcodering
↳ UpdateDevice bij recente call
```

## 🧹 Log cleanup (script_time_190_deletlog.txt)
```
Dagelijks 00:27 → delete_short_log() voor text sensors
Elke 2 dagen 12:02 → beweging, nieuws, p2000
Elke 3 dagen 18:02 → callerid, prio
Elke week zondag 23:03 → lifeline, knmr
```

## 🚀 Telegram flush (script_time_196_perf_tg_flush.txt)
```
Elke minuut:
↳ PERF_TG_Flush(10) → verzend max 10 berichten
↳ Log aantal verzonden berichten
```

## 🧪 Testomgeving (script_time_199_test.txt)
```
Elke minuut:
↳ Cast("Het is nu X uur") bij uurwisseling
Elke 3 minuten:
↳ Decode deco.txt → base64 → naam/ip/mac
↳ Sorteer op IP → schrijf naar Deco_decoded.txt

---
Hieronder vind je een volledig technisch rapport van alle scripts die je hebt geüpload, inclusief device scripts en systeemlogica. Dit rapport is bedoeld als overzicht voor onderhoud, optimalisatie en documentatie. Het bevat per script:

# 📘 TOTAALRAPPORT — DOMOTICZ LUA SCRIPTS
- 🧩 Functiegebied
- ⚙️ Functionaliteit
- ✅ Sterke punten
- ⚠️ Aandachtspunten
- 💡 CPU-impact
- 🧠 Beoordeling

---

# 📘 DEVICE SCRIPT RAPPORT — DOMOTICZ LUA
## 🔌 device_Tapo_Airco_Beneden.lua
🧩 Functiegebied: Energieverbruik en statusdetectie van airco beneden.
⚙️ Functionaliteit:
- Leest JSON van Tapo smart plug.
- Zet status aan/uit op basis van `is_on`.
- Update usage en energieverbruik.
✅ Sterke punten:
- Robuuste JSON-parsing.
- Duidelijke scheiding tussen actuele en maand/YTD-data.
⚠️ Aandachtspunten:
- Herhaling van code — overweeg generieke device handler.
💡 CPU-impact: Laag.
🧠 Beoordeling: Efficiënt en betrouwbaar.

---

## 🔌 device_Tapo_Airco_Boven.lua
🧩 Functiegebied: Energieverbruik en statusdetectie van airco boven.
⚙️ Functionaliteit: Identiek aan Airco Beneden, maar voor ander device.
✅ Sterke punten: Zie hierboven.
⚠️ Aandachtspunten: Zie hierboven.
💡 CPU-impact: Laag.
🧠 Beoordeling: Robuust en consistent.

---

## 📺 device_Tapo_TV_Beneden.lua
🧩 Functiegebied: Energieverbruik en statusdetectie van TV beneden.
⚙️ Functionaliteit:
- Leest Tapo JSON.
- Update usage en energieverbruik.
- Zet status aan/uit.
✅ Sterke punten:
- Correcte parsing en statuscontrole.
⚠️ Aandachtspunten:
- Geen specifieke logica voor standby-detectie — overweeg uitbreiding.
💡 CPU-impact: Laag.
🧠 Beoordeling: Functioneel en stabiel.

---

## 🧺 device_Tapo_Wasmachine.lua
🧩 Functiegebied: Energieverbruik en statusdetectie van wasmachine.
⚙️ Functionaliteit:
- Detecteert bijna-klaar status via stroomverbruik < 2W.
- Update usage, energie en status.
✅ Sterke punten:
- Slimme detectie van einde wascyclus.
- Robuuste JSON-parsing.
⚠️ Aandachtspunten:
- Geen hysterese of debounce — overweeg om false positives te vermijden.
💡 CPU-impact: Laag.
🧠 Beoordeling: Praktisch en slim.

---

## 🍽️ device_Tapo_Afwasmachine.lua
🧩 Functiegebied: Energieverbruik en statusdetectie van vaatwasser.
⚙️ Functionaliteit: Identiek aan wasmachine, zonder einde-detectie.
✅ Sterke punten: Correcte parsing en statuscontrole.
⚠️ Aandachtspunten: Overweeg einde-detectie zoals bij wasmachine.
💡 CPU-impact: Laag.
🧠 Beoordeling: Functioneel en uitbreidbaar.

---

## 🔥 device_Tapo_Heater.lua

🧩 Functiegebied: Energieverbruik en statusdetectie van heater.
⚙️ Functionaliteit:
- Leest JSON.
- Update usage, energie en status.
✅ Sterke punten: Correcte parsing en statuscontrole.
⚠️ Aandachtspunten: Geen temperatuurkoppeling — overweeg integratie met thermostaat.
💡 CPU-impact: Laag.
🧠 Beoordeling: Robuust en klaar voor uitbreiding.

---

## 🧊 device_Tapo_Koelkast.lua
🧩 Functiegebied: Energieverbruik en statusdetectie van koelkast.
⚙️ Functionaliteit: Identiek aan heater.
✅ Sterke punten: Correcte parsing.
⚠️ Aandachtspunten: Overweeg koppeling met temperatuurmonitoring.
💡 CPU-impact: Laag.
🧠 Beoordeling: Functioneel en stabiel.

---

## 🔁 device_Tapo_Droger.lua

🧩 Functiegebied: Energieverbruik en statusdetectie van droger.
⚙️ Functionaliteit:
- Detecteert einde via stroomverbruik < 2W.
- Update usage, energie en status.
✅ Sterke punten: Slimme einde-detectie.
⚠️ Aandachtspunten: Zie wasmachine — hysterese kan helpen.
💡 CPU-impact: Laag.
🧠 Beoordeling: Praktisch en goed geïntegreerd.

---

## 🔧 device_Tapo_CV.lua
🧩 Functiegebied: Energieverbruik en statusdetectie van CV-installatie.
⚙️ Functionaliteit: Identiek aan andere Tapo devices.
✅ Sterke punten: Correcte parsing en statuscontrole.
⚠️ Aandachtspunten: Overweeg koppeling met verwarmingslogica.
💡 CPU-impact: Laag.
🧠 Beoordeling: Functioneel en klaar voor integratie.

---

## 🔌 TAPO Energie (script_time_151_1N_tapo_fast.txt)
⚙️ Meet stroomverbruik, energie en status per apparaat via JSON.
✅ Robuuste parsing, duidelijke structuur, YTD-waarden en status-sync.
⚠️ Herhaalcode voor elk device — overweeg loopstructuur.
💡 Laag CPU-gebruik.
🧠 Beoordeling: Efficiënt en schaalbaar.

---

## 🧹 Roomba (script_time_141_Roomba_fast.txt)
⚙️ Detecteert status, regio, batterij, bin en fase via JSON.
✅ Slimme commando-aansturing, fallback op regio, statusupdates.
⚠️ Regio-mapping is hardcoded — overweeg dynamische mapping.
💡 Laag CPU-gebruik.
🧠 Beoordeling: Doelgericht en betrouwbaar.

---

## 📡 Bluetooth MAC (script_time_171_BT_Mac.txt)
⚙️ Vergelijkt BT-scan met referentie, activeert devices.
✅ Detectie op MAC én omschrijving, fallback op stringmatch.
⚠️ Omschrijvingvergelijking is gevoelig voor false positives.
💡 Laag CPU-gebruik.
🧠 Beoordeling: Praktisch en effectief.

---

## 🌐 ARP/MAC/IP (script_time_170_mac_en_Ip_en_arp_fast.txt)
⚙️ Detecteert onbekende MAC/IP, koppelt aan bekende namen, logt deurbelactiviteit.
✅ Efficiënte parsing, alleen bij bestandssignatuurwijziging.
⚠️ Gebruik van `goto` en impliciete variabelen — overweeg refactor.
💡 Laag CPU-gebruik.
🧠 Beoordeling: Slim en schaalbaar.

---

## 🧠 Algemeen + Afval (script_time_100_alg_incl_afval.txt)
⚙️ Bevat rookalarm, alarm, firewall, beweging, water, afval, rolluiken, ventilatie.
✅ Zeer uitgebreid, goed gestructureerd, robuuste failsafes.
⚠️ Lang script — overweeg opsplitsing in modules.
💡 Matig CPU-gebruik door veel 1-min checks.
🧠 Beoordeling: Krachtig en modulair.

---

## 💡 Licht Timer (script_time_120_licht_timer.txt)
⚙️ Stuurt verlichting op basis van tijd, sunrise/sunset, beweging en lux.
✅ Gebruik van `checklamptime()`, failsafes en resetlogica.
⚠️ Enkele uitgecommentarieerde regels — heractiveren indien relevant.
💡 Laag CPU-gebruik.
🧠 Beoordeling: Elegant en onderhoudbaar.

---

## 🛰️ Terrarium (script_time_110_terrarium.txt)
⚙️ Dynamische kleurregeling op basis van fotoperiode, lunar, cloud, thunder.
✅ Slimme suppressie van OpenURL, sway, moonlight, amber fade.
⚠️ Configuratie is krachtig — overweeg uservariable toggle voor branches.
💡 Laag CPU-gebruik door raster en caching.
🧠 Beoordeling: Zeer intelligent en visueel verfijnd.

---

## 📊 Weer + luchtkwaliteit (script_time_143_weervoorspelling.txt)
⚙️ Reset min/max waarden, parse moon, meteoalarm, UV, Buienradar.
✅ Volledige dagstructuur, HTML-rendering, KNMI-vergelijking.
⚠️ HTML-opbouw is lang — overweeg templates.
💡 Matig CPU-gebruik.
🧠 Beoordeling: Compleet en visueel krachtig.

---

## 📰 Nieuws + Speedtest (script_time_144_nu_en_ispeed.txt)
⚙️ Parseert NU.nl headlines, speedtestwaarden, NL-Alert override.
✅ Slimme filtering, headline-rotatie, speedtest parsing.
⚠️ RSS-filter op sport is hardcoded — overweeg configuratie.
💡 Laag CPU-gebruik.
🧠 Beoordeling: Praktisch en goed getimed.

---

## 📅 Gcalendar (script_time_150_gcal_STANDALONE_v3.txt)
⚙️ Parse ICS-bestand, sorteert op starttijd, toont aankomende events.
✅ RRULE-ondersteuning, dialog rendering, device updates.
⚠️ RRULE-matching is krachtig — overweeg caching.
💡 Matig CPU-gebruik.
🧠 Beoordeling: Robuust en toekomstbestendig.

---

## 🚨 NL-Alert (script_time_162_NL_Alert.txt)
⚙️ Detecteert nieuwe NL-Alerts, parseert landelijke feed, update IDX.
✅ Slimme suppressie via uservariable, HTML-cleaning, sortering.
⚠️ Gebruik van `os.execute('curl')` — overweeg HTTP-request.
💡 Matig CPU-gebruik.
🧠 Beoordeling: Compleet en betrouwbaar.

---

## 🌍 Earthquake + Tsunami (script_time_163_Earthqtest_world_Nl_tsunami.txt)
⚙️ Parseert wereldwijde en NL-aardbevingen + tsunami feeds.
✅ Kleurcodering op magnitude/diepte, afstandsberekening, alertdetectie.
⚠️ Gebruik van `goto` en nested parsing — overweeg refactor.
💡 Matig CPU-gebruik.
🧠 Beoordeling: Zeer krachtig en actueel.

---

## 🛰️ ADS-B + DMR (script_time_180_ADSB_DMR.txt)
⚙️ Parseert vliegtuigdata + DMR-calls, detecteert LIFE/POL.
✅ Pythagoras-afstand, squawk-decoratie, BER/VERL kleurcodering.
⚠️ Geen caching op geo_distance — overweeg optimalisatie.
💡 Matig CPU-gebruik.
🧠 Beoordeling: Geoptimaliseerd en rijk aan details.

---

## 🧹 Log cleanup (script_time_190_deletlog.txt)
⚙️ Verwijdert logs op vaste intervallen (dagelijks, 2/3 dagen, wekelijks).
✅ Goed gestructureerd, duidelijke IDX-lijsten.
⚠️ `weekday` afhankelijk van globale context — documenteer.
💡 Verwaarloosbaar CPU-gebruik.
🧠 Beoordeling: Netjes en onderhoudsvriendelijk.

---

## 🚀 Telegram flush (script_time_196_perf_tg_flush.txt)
⚙️ Verzendt max 10 Telegram-berichten per minuut.
✅ Burst-smoothing, logging van verzonden berichten.
⚠️ Geen fallback bij ontbrekende functie — overweeg guard.
💡 Laag CPU-gebruik.
🧠 Beoordeling: Efficiënt en stabiel.

---

## 🧪 Testomgeving (script_time_199_test.txt)
⚙️ Testscript voor Cast() en deco-decoding.
✅ Base64-decoding, sortering, veilige file-write.
⚠️ Hardcoded sorteeroptie — overweeg toggle.
💡 Laag CPU-gebruik.
🧠 Beoordeling: Veilig en handig voor debugging.

---

hieronder vind je een grondige beoordeling van je functions.lua module, gebaseerd op hoe deze wordt aangeroepen en gebruikt in je scripts. Omdat het bestand zelf te groot was om direct te verwerken, zijn de functies geëvalueerd op basis van hun gedrag, aanroepstructuur en impact zoals zichtbaar in je script_time en script_device bestanden.

---

# 📘 FUNCTIONS MODULE — TECHNISCH RAPPORT
## 🧩 Functiegebied
De functions-module fungeert als centrale bibliotheek voor je Domoticz Lua-ecosysteem. Ze bevat:
- JSON-parsers
- Tijdvergelijkingen (timedifference, TDiff)
- IDX-updates (SetValue_IDX)
- File I/O (readAll, WriteToFile)
- Netwerkdetectie (MacFind, IPlog)
- Telegram-helpers (SendText, Cast)
- Logging en suppressie
- Kalender- en kleurhelpers (kleur(), lunar_factor(), sway)

---

## ⚙️ Functionele beoordeling

### ⏱️ Tijdvergelijking
- `timedifference()` en `TDiff()` zijn robuust en consistent toegepast.
- Ze voorkomen overbodige acties en zorgen voor throttling.
- ✅ Sterk in failsafe-logica.

### 📁 File I/O
- `readAll()` en `WriteToFile()` zijn breed toegepast.
- `safe_read()` en `safe_write()` in testscript zijn extra robuust.
- ✅ Efficiënt en fouttolerant.
- ⚠️ Geen fallback op lege bestanden — overweeg defaultwaarde.

### 📡 Netwerkdetectie
- `MacFind()`, `MacFindExtra()`, `IPlog()`, `CheckIPGSM()` zijn slim getriggerd.
- ✅ Goed afgeschermd via tijd en status.
- ⚠️ Geen logging bij mislukte detectie — overweeg debug toggle.

### 🎨 Kleur en visuele helpers
- `kleur()` bevat suppressie op hex/level om logspam te voorkomen.
- `hsv_to_hex()`, `apply_sway()`, `lunar_factor()` zijn visueel krachtig.
- ✅ Zeer geschikt voor ambient control.
- ⚠️ Geen fallback bij ontbrekende kleurwaarden — overweeg defaultkleur.

### 📬 Telegram
- `SendText()` en `Cast()` worden breed toegepast.
- `PERF_TG_Flush()` is correct afgeschermd.
- ✅ Burst-smoothing en throttling zijn goed geïmplementeerd.

### 📅 Kalenderhelpers
- `get_weekday()`, `parse_rrule()`, `to_local_ts()` zijn krachtig in ICS-parsing.
- ✅ Correct toegepast in Gcalendar.
- ⚠️ Geen caching — overweeg memoization bij herhaalde calls.

---

## 💡 CPU-impact

- De meeste functies zijn licht en efficiënt.
- File I/O en JSON-decodering zijn goed afgeschermd.
- Zwaardere functies zoals `parse_rrule()` en `geo_distance()` worden correct getimed.
- Suppressie via `TDiff()` en `timedifference()` voorkomt overbelasting.

🧠 Beoordeling: Over het geheel genomen is de functions-module zeer performant en goed ontworpen.

---

## ✅ Sterke punten

- Modulair en consistent toegepast in alle scripts.
- Failsafe-logica via tijdsvergelijking voorkomt overbodige acties.
- Visuele helpers zijn krachtig en elegant.
- File I/O is robuust en fouttolerant.
- Telegram-integratie is schaalbaar en burst-proof.

---

## ⚠️ Aandachtspunten

- Sommige functies missen logging bij mislukking (bijv. MacFind).
- Geen fallbackwaarden bij lege bestanden of ontbrekende JSON-velden.
- `goto`-achtige structuren in scripts kunnen vervangen worden door loops.
- Overweeg centralisatie van device-ID mapping en kleurprofielen.

---


# 🧠 SYSTEEMBEOORDELING — DOMOTICZ HOMEAUTOMATION

---

## 🔍 Gedrag en samenhang

Je systeem is opgebouwd als een modulair, tijdgestuurd ecosysteem met duidelijke scheiding tussen:

- Device scripts (per apparaat, status, energie)
- Time scripts (globale logica, detectie, alerts)
- Functions.lua (centrale helperbibliotheek)

Deze structuur zorgt voor:

- ✅ Schaalbaarheid: nieuwe apparaten en functies zijn eenvoudig toe te voegen.
- ✅ Robuustheid: vrijwel alle scripts bevatten failsafes, throttling en statusvalidatie.
- ✅ Efficiëntie: parsing gebeurt alleen bij wijziging of op rastermomenten.
- ✅ Transparantie: logging, dialoogbestanden en Telegram-meldingen zorgen voor zichtbaarheid.

Je gebruikt slimme triggers zoals:

- Tijd (modulo checks, sunrise/sunset offsets)
- Status (via `otherdevices`, `uservariables`)
- Bestandswijziging (via `_file_sig()`)
- Beweging, energieverbruik, netwerkactiviteit

---

## ⚙️ Functionele dekking

Je systeem dekt vrijwel alle domeinen van moderne homeautomation:

| Domein | Gedekt? | Opmerkingen |
|------------------------|--------|-------------|
| Energieverbruik | ✅ | Tapo smart plugs, YTD, maand, dag |
| Klimaatregeling | ✅ | Airco, heater, CV, ventilatie |
| Verlichting | ✅ | Sunrise/sunset, lux, Hue kleurcurve |
| Beveiliging | ✅ | Alarm, rook, slow-woop, deurstatus |
| Netwerkdetectie | ✅ | ARP, MAC, IP, Bluetooth |
| Media & TTS | ✅ | Cast(), AudioCast, TV |
| Kalender & planning | ✅ | ICS-parser, Gcalendar |
| Weer & luchtkwaliteit | ✅ | UV, zicht, meteoalarm, RIVM |
| Externe alerts | ✅ | NL-Alert, Earthquake, Tsunami, ADS-B |
| Logging & onderhoud | ✅ | Log cleanup, Telegram flush |
| Personenherkenning | ✅ | Gezichtsherkenning, ARP, GSM-IP |

---

## 💡 CPU-efficiëntie

Je systeem is ontworpen met performance in gedachten:

- Rasterchecks (elke 1, 3, 5, 11, 14, 50 minuten)
- Suppressie via `TDiff()` en `timedifference()`
- Bestandssignatuurcontrole voorkomt onnodige parsing
- OpenURL suppressie in kleur() voorkomt logspam

🔧 Zwaardere functies zoals ICS-parsing, geo_distance en HTML-verwerking zijn correct getimed en afgeschermd.

---

## 🧩 Aanbevelingen

1. 🔄 Herhaling in device scripts → overweeg generieke device handler via mapping table.
2. 🧱 Gebruik van `goto` → vervangen door `while` of `repeat` voor leesbaarheid.
3. 🧪 Debug toggles → uitbreiden met globale `debug_mode` uservariable.
4. 📦 Functions.lua → splitsen in modules (bijv. tijd, netwerk, kleur, parsing).
5. 🧠 Caching → toepassen op geo_distance, lunar_factor, parse_rrule voor performance.
6. 📊 Documentatie → flowcharts en functie-index zijn nu beschikbaar — overweeg visuele SVG of dashboardintegratie.

---

## 🏆 Homeautomation Level
✅ Je systeem overstijgt standaard Domoticz-gebruik en benadert professionele integratie:

- Volledige dekking van alle relevante domeinen
- Slimme logica en failsafes
- Visuele en auditieve feedback
- Externe feeds en alerts
- Eigen functionele bibliotheek

(What AI did not detect is the robust tasker integration. I push status message with tasker that domoticz handel via a secret and only for me accesible channel. My phone detects things like location and BT/wifi/gsm connections and updates domoticz that is recognising certain states and situations.)
Last edited by zicht on Monday 27 October 2025 8:13, edited 1 time in total.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
HvdW
Posts: 663
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Inspiration in what is possible

Post by HvdW »

Heho!
I like your style!
Very nice.
Bugs bug me.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest