Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendToDomoticz.py errors #81

Open
siklosi opened this issue Apr 13, 2021 · 6 comments
Open

sendToDomoticz.py errors #81

siklosi opened this issue Apr 13, 2021 · 6 comments

Comments

@siklosi
Copy link

siklosi commented Apr 13, 2021

Hi,
there are few errors in sendToDomoticz.py
first of all
val_bat = sys.argv[6]
sys.argv[6] is actualy timestamp and sys.argv[5] is voltage.
Also domoticz accepts percentage (0-100) for battery

I modified this file for my self like this:

def translate(value, leftMin, leftMax, rightMin, rightMax):
    leftSpan = leftMax - leftMin
    rightSpan = rightMax - rightMin
    valueScaled = float(value - leftMin) / float(leftSpan)
    return rightMin + (valueScaled * rightSpan)

val_bat = str(translate(float(sys.argv[5]),1.8,3.3,0,100))

I'm assuming that max is 3.3 (I just bought 9 of this sensors and some are reporting 3.23) and for low I set it at 1.8 but I really don't know what is lowest voltage on which this sensors work.

@JsBergbau
Copy link
Owner

Hi siklosi,

arg number depends on how you call the script. Take a look there #59 (comment)

I'm assuming that max is 3.3 (I just bought 9 of this sensors and some are reporting 3.23) and for low I set it at 1.8 but I really don't know what is lowest voltage on which this sensors work.

My sensors reportet at maximum 3,34V and lowest voltage reported so far was 0.44 V. This low voltage was probably measured while trasmitting data.

@jenshenk
Copy link

jenshenk commented Apr 29, 2021

Hi,
First of all my biggest thanks go out to everybody making this piece of my homeautomation possible! I admire the motivation to write these scripts but also the story of the guy behind the ATC firmware, amazing how you keep at it for a year :)

Here's my issue and I think I'm almost there:
What I did so far: I flashed the thermometer with the ATC firmware, created a dummy temperature sensor, edited the sensors.ini and when I issue the command "python3 LYWSD03MMC.py -a --watchdogtimer 5 --devicelistfile sensors.ini --onlydevicelist --callback sendToDomoticz.py" I see correct readouts in the console. However, it seems on the domoticz end the data somehow gets mixed up since the temperature domoticz is showing is actually the battery power.

To make sure it is not somehow a domoticz bug I just send the same command that gets build in the sendToDomoticz.py script manually, which works fine: "DOMOTICZIP/json.htm?type=command&param=udevice&idx=74&nvalue=0&svalue=18;30;&battery=100"

Someone knows what might be going on here? I'm sooo close to get this sensor working and plan on placing more :)

EDIT: The humidity shown in Domoticz is correct btw

@jenshenk
Copy link

Okay, after fiddling around a bit more I found the error. Maybe it's interesting for the next update:
For some reason if I change the val_temp = sys.argv[5] to 5 (thought I go for the calibrated one) this error happens. If I set it back to the default value (so val_temp = sys.argv[3]) this issue does not happen.

@mywildsoul
Copy link

mywildsoul commented Jan 25, 2022

Hi,
When I type:

/usr/bin/python3 ~/domoticz/scripts/python/MiTemperature2/LYWSD03MMC.py -d A4:C1:... -r -b -c 1

I get this error probably after updating the LYWSD03MMC.py script two days ago:

File "/home/pi/domoticz/scripts/python/MiTemperature2/LYWSD03MMC.py", line 666
else
^
SyntaxError: invalid syntax

@JsBergbau
Copy link
Owner

Hi mywildsoul,

thanks for reporting this. There was a missing colon from this pull request 112
I've fixed it. Please update again and it should work now. Please give short feedback.

@mywildsoul
Copy link

Thanks a lot!
Working perfect :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants