fix openhab error: Rule ‘[rulename]’: An error occurred during the script execution: index=0, size=0

My goal is to execute an python-script when the Battery-charge has reached 70%

My rule was not executed, the error as shown above is seen in the log.
My faulty script:

rule "BYD 70"

when
     Item KOSTALPLENTICOREPlus70WithBattery_BatteryCharge received update



then
	var BYDBat = (KOSTALPLENTICOREPlus70WithBattery_BatteryCharge.state as Number).floatValue

	if ((KOSTALPLENTICOREPlus70WithBattery_BatteryCharge.state as Number).floatValue = 70.0) {


	sendTelegram("bot1",
            "BYD hat > 70  % Ladung " + BYDBat)
	executeCommandLine("python3 /etc/openhab2/scripts/BYDI.py")
	logDebug("logtest", "BYDBat = " + BYDBat)
        logDebug("logtest", "state = " + KOSTALPLENTICOREPlus70WithBattery_BatteryCharge.state)
}

end

Reason of the error: the if-statement is misleading, to check if the value is equal it needs two “==”:


	if ((KOSTALPLENTICOREPlus70WithBattery_BatteryCharge.state as Number).floatValue == 70.0) {

working-code:

rule "BYD 70"

when
     Item KOSTALPLENTICOREPlus70WithBattery_BatteryCharge received update



then
	var BYDBat = (KOSTALPLENTICOREPlus70WithBattery_BatteryCharge.state as Number).floatValue

	if ((KOSTALPLENTICOREPlus70WithBattery_BatteryCharge.state as Number).floatValue == 70.0) {


	sendTelegram("bot1",
            "BYD hat > 70  % Ladung " + BYDBat)
	executeCommandLine("python3 /etc/openhab2/scripts/BYDI.py")
	logDebug("logtest", "BYDBat = " + BYDBat)
        logDebug("logtest", "state = " + KOSTALPLENTICOREPlus70WithBattery_BatteryCharge.state)
}

end

to debug BYDBat/KOSTALPLENTICOREPlus70WithBattery_BatteryCharge.state debugging needs to be enabled like shown at: https://www.cipv6.de/worp/index.php/2019/10/23/how-do-i-debug-tradfri-on-openhab/

openhab> log:get org.eclipse.smarthome.model.script
DEBUG
openhab> log:set Info org.eclipse.smarthome.model.script
openhab> log:get org.eclipse.smarthome.model.script
INFO

Send Geo-location from Browser

Create a button and log the current LAT/LON when the button is pressed:

<button id="send-location"> Send location</button>
document.querySelector('#send-location').addEventListener('click', () => {

    if (!navigator.geolocation) {

        return alert ('Geolocation not supported by Browser !')

    }
    
    navigator.geolocation.getCurrentPosition((position) => {

        console.log(position)

    })

console.log output

Java: Remove brackets / leading slashes from String

My Android-app have always presented the DNS-Server(s) with brackets / leading slashes like:

How can we get rid of these unnecessary characters ?

String myIp2Dns1:

String myIp2Dns1 = String.valueOf (LinkProp.getDnsServers()) ;

Log:

Log.d("myDnsInfo - Domain - ", "Domain = " + LinkProp.getDomains());
D/myDnsInfo: dns = [/10.0.2.3]

Solution:
Manipulation of String myIp2Dns1:

myIp2Dns1 = myIp2Dns1.replaceAll("[\\[\\](){}\"^/+\"]","");

This command removes brackets / slashes / backslashes from the String.

The output looks much better now:

Home Assistant 2021.2.3 on Pi4 running Home Assistant OS: Fix Dyson add-on

Home Assistant 
Oveniew 
Innux0B 
Brows« 
ration 
Dashboard 
Addnn SWe 
Snapshots 
q port 
No results found in •Official add-ons.' 
Home Assistant Community Add-ons 
Port a i 
Manage your with
on Home-assistant click on Supervisor / Add-on Store and search for Portainer
Portainer 
1.410 (change!Q9) 
Manage Four Docket with ease, 
details 
portainer.io 
oeoo 
Stut 
Make the addon start dwinga system boot 
This win starl the if it cashes 
Auto update the addon when there is a new versicm avadable 
ion mod e 
glcrcks elevated svslem access from the add-on 
Hostna me 
Addon CPU usage 
Add•on RAM usage 
OPEN ul
disable Protection-Mode , enable Show in Sidebar. Start/Restart Portainer
Home Assistant 
Story 
Terminal 
Configwation 
iport 
alner.10 
PRI MARY 
App tes 
Conta i nerS 
Endpo 
Reg 
Settings 
non-a m s 
Dinble privileged mode fM 
Enable volume management for non-administrators O 
Enable host mangement 
Edge Compute 
Edge agent poll 
frequency O 
edge featuws 
Hidden containers 
hid. with u'. to sp„ify 
Value 
h sta nt 
e.g. bar
Click on Portainer in the Sidebar, click Settings . Remove core and homeassistant from the hidden Containers
Home Assistant 
Logbook 
History 
InnuxDB 
Terminal 
Media 
portainer.io 
pm MARY 
App plates 
Registries 
Container list 
Containers 
q search... 
Name 
iten(sl ted 
state 
Quick actions 
Stac 
mage 
"i sta 64• 2021.23 
2021-02-21 '287.47 
portainør support 
Columns Settings 
pub hed ports 
10
highlight the Container and click on exec
iii
click on Connect

Paste the following lines:

cd /usr/local/lib/python3.8/site-packages/libpurecool/

cd /usr/local/lib/python3.8/site-packages/libpurecool/
rm dyson.py
curl -O https://raw.githubusercontent.com/bfayers/libpurecool/auth_customdeps/libpurecool/dyson.py
Home Assistant 
Ovewiew 
Map 
stMy 
Teminal 
Server Controls 
Restart and Stop the ASS i Stant server 
Sew« 
Configuration validation 
Validate configuration if recently made some to your and 
make Sure that it is all valid 
Server management 
your A SSiStant server. from Home Assistant 
Rtsrz 
STOP 
YAML configuration reloading 
Sm parts of Assistant Qn a Hitting will 
unload their current YAML load new 
RELOAD LOCATION 
RELOAD AUTOMAr.ONS 
RELOAD GROUPS. GROUP ENTITIES. ANO GROUP NOTIFY SERVICES 
RELOAD INPUT BOOLEANS 
RELOAD 
RELOAO INPUT NUMBERS
Restart Home-Assistant

Now the Dyson-Device is connected:

-Done!