Das mit der Ruhe ist so eine Sache...
Hab jetzt die Ansicht geändert, Ordner sind da.
Ich Danke Dir.
NEWS
Steinmetz_4
@Steinmetz_4
Blutiger Anfänger, der sich alles "rausgoogelt"
Best posts made by Steinmetz_4
-
RE: Gelöst: Raspi stirbt nach Backup ab
-
[Gelöst:] Adjust settings in the .env File
Servus,
ich wollte heute den Ds18b20 die Sensoren auf einem anderen System anzeigen lassen.
Soweit bin ich bisher, aber ich kann mir keinen Reim auf "Please adjust the settings in the .env file." machen.Kann mir jemand weiterhelfen?
pi@pi4-Master:~ $ mkdir ~/ds18b20-remote pi@pi4-Master:~ $ cd ~/ds18b20-remote pi@pi4-Master:~/ds18b20-remote $ wget -O remote-client-setup.js http://192.168.178.68:8081/adapter/ds18b20/remote-client-setup.js --2022-11-23 09:48:58-- http://192.168.178.68:8081/adapter/ds18b20/remote-client-setup.js Connecting to 192.168.178.68:8081... connected. HTTP request sent, awaiting response... 200 OK Length: 39797 (39K) [application/javascript] Saving to: ‘remote-client-setup.js’ remote-client-setup 100%[===================>] 38.86K --.-KB/s in 0.003s 2022-11-23 09:48:58 (14.5 MB/s) - ‘remote-client-setup.js’ saved [39797/39797] pi@pi4-Master:~/ds18b20-remote $ node remote-client-setup.js - ioBroker.ds18b20 remote client - Basic setup done. Please adjust the settings in the .env file. To manually start the client just run: node ds18b20-remote-client.js To setup the SystemD service, please run: sudo cp iobroker-ds18b20-remote.service /etc/systemd/system/iobroker-ds18b20-remote.service sudo systemctl daemon-reload sudo systemctl enable iobroker-ds18b20-remote.service sudo systemctl start iobroker-ds18b20-remote.service
pi@pi4-Master:~/ds18b20-remote $ sudo nano remote-client-setup.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs = require("fs"); const os = require("os"); const path = require("path"); const SYSTEMD_SERVICE_NAME = 'iobroker-ds18b20-remote.service'; const files = { 'common.js': 'InVzZSBzdHJpY3QiOwpPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCB7IHZhbHVlOiB0cnVlIH0pOwpleHBvcnRzLmRlY3J5cHQgPSBleHBvcnRzLmVuY3J5cHQgPSBleHBvcnRzLlJFTU9URV9QUk9UT0NPTF9WRVJTSU9OID0gdm9pZCAwOwpjb25zdCBjcnlwdG8gPSByZXF1aXJlKCJjcnlwdG8iKTsKZ> 'ds18b20-remote-client.js': 'InVzZSBzdHJpY3QiOwp2YXIgX19hd2FpdGVyID0gKHRoaXMgJiYgdGhpcy5fX2F3YWl0ZXIpIHx8IGZ1bmN0aW9uICh0aGlzQXJnLCBfYXJndW1lbnRzLCBQLCBnZW5lcmF0b3IpIHsKICAgIGZ1bmN0aW9uIGFkb3B0KHZhbHVlKSB7IHJldHVybiB2YWx1ZSBpbnN0YW5jZW9mIFAgPyB2YWx1ZSA6IG5ldyBQKGZ1bmN0aW> 'logger.js': 'InVzZSBzdHJpY3QiOwpPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCB7IHZhbHVlOiB0cnVlIH0pOwpleHBvcnRzLkxvZ2dlciA9IHZvaWQgMDsKY2xhc3MgTG9nZ2VyIHsKICAgIGxvZyguLi5hcmdzKSB7CiAgICAgICAgY29uc29sZS5sb2coLi4uYXJncyk7CiAgICB9CiAgICBkZWJ1ZyguLi5hcmdzKSB7C> }; for (const f in files) { const content = Buffer.from(files[f], 'base64').toString('utf-8'); fs.writeFileSync(f, content, { encoding: 'utf-8' }); } const systemDContent = `[Unit] Description=ioBroker.ds18b20 remote client Documentation=https://github.com/crycode-de/ioBroker.ds18b20 After=network.target [Service] Type=simple User=${os.userInfo().username} WorkingDirectory=${__dirname} ExecStart=${process.execPath} ${path.join(__dirname, 'ds18b20-remote-client.js')} Restart=on-failure [Install] WantedBy=multi-user.target `; const systemDFile = path.join(__dirname, SYSTEMD_SERVICE_NAME); fs.writeFileSync(systemDFile, systemDContent, { encoding: 'utf-8' }); const dotEnvContent = `# Settings for the ioBroker.ds18b20 remote client # Unique ID for this remote system SYSTEM_ID=my-remote # IP or hostname of the ioBroker host running the adapter ADAPTER_HOST=192.168.178.68 # Port from the adapter config ADAPTER_PORT=1820 # Encryption key from the adapter config ADAPTER_KEY=35305d096dc8eef7db46d575417926bafxxxxxxxxxxxxxxxxxxxxxx # Enable debug log output #DEBUG=1 # System path of the 1-wire devices #W1_DEVICES_PATH=/sys/bus/w1/devices `; const dotEnvFile = path.join(__dirname, '.env'); if (!fs.existsSync(dotEnvFile)) { fs.writeFileSync(dotEnvFile, dotEnvContent, { encoding: 'utf-8' }); } console.log(`- ioBroker.ds18b20 remote client - Basic setup done. Please adjust the settings in the .env file. To manually start the client just run: node ds18b20-remote-client.js To setup the SystemD service, please run: sudo cp ${SYSTEMD_SERVICE_NAME} /etc/systemd/system/${SYSTEMD_SERVICE_NAME} sudo systemctl daemon-reload sudo systemctl enable ${SYSTEMD_SERVICE_NAME} sudo systemctl start ${SYSTEMD_SERVICE_NAME} `); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2V0dXAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcmVtb3RlL3NldHVwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBTUEseUJBQXlCO0FBQ3pCLHlCQUF5QjtBQUN6Qiw2QkFBNkI7QUFFN0IsTUFBTSxvQkFBb>
pi@pi4-Master:~/ds18b20-remote $ node ds18b20-remote-client.js - ioBroker.ds18b20 remote client - [Error] No ADAPTER_HOST given!
pi@pi4-Master:~/ds18b20-remote $ sudo systemctl status iobroker-ds18b20-remote.service ● iobroker-ds18b20-remote.service - ioBroker.ds18b20 remote client Loaded: loaded (/etc/systemd/system/iobroker-ds18b20-remote.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2022-11-23 10:56:00 CET; 23s ago Docs: https://github.com/crycode-de/ioBroker.ds18b20 Process: 10290 ExecStart=/usr/bin/node /home/pi/ds18b20-remote/ds18b20-remote-client.js (code=exited, status=1/FAILURE) Main PID: 10290 (code=exited, status=1/FAILURE) CPU: 183ms Nov 23 10:56:00 pi4-Master systemd[1]: iobroker-ds18b20-remote.service: Scheduled restart job, restart counter is at 5. Nov 23 10:56:00 pi4-Master systemd[1]: Stopped ioBroker.ds18b20 remote client. Nov 23 10:56:00 pi4-Master systemd[1]: iobroker-ds18b20-remote.service: Start request repeated too quickly. Nov 23 10:56:00 pi4-Master systemd[1]: iobroker-ds18b20-remote.service: Failed with result 'exit-code'. Nov 23 10:56:00 pi4-Master systemd[1]: Failed to start ioBroker.ds18b20 remote client. pi@pi4-Master:~/ds18b20-remote $
Für alle die auch nicht so gut auf Linux sind, die Lösung ist:
pi@pi4-Master:~/ds18b20-remote $ sudo nano .env
sieht dann so aus:
# Settings for the ioBroker.ds18b20 remote client # Unique ID for this remote system SYSTEM_ID=Pi-4-Master # IP or hostname of the ioBroker host running the adapter ADAPTER_HOST=192.168.178.68 # Port from the adapter config ADAPTER_PORT=1820 # Encryption key from the adapter config ADAPTER_KEY=dea3458098c294f22546bbd5367a224a4b9082808xxxxxxxxx # Enable debug log output #DEBUG=1 # System path of the 1-wire devices #W1_DEVICES_PATH=/sys/bus/w1/devices
Mfg
Tom
Latest posts made by Steinmetz_4
-
RE: [Gelöst] MQTT-Verbindung via Python script
Tada, es funktioniert!
Ich danke Dir!
War ein holpriger Weg aber es läuft...Habe beide Punkte auskommentiert.
P.S. Ich bin die Ruhe in Person...
Mfg
Tom -
RE: [Gelöst] MQTT-Verbindung via Python script
@homoran sagte in MQTT-Verbindung:
@steinmetz_4 sagte in MQTT-Verbindung:
Ich denke schon.
jepp! dann ist die Frage auch eindeutig geklärt
Verzeiht
Ich weiß, dass ich nichts weiß (https://de.wikipedia.org/wiki/Ich_weiß,_dass_ich_nichts_weiß)
-
RE: [Gelöst] MQTT-Verbindung via Python script
Sorry, nein !
ich tüftel an allen Ecken und Enden!#
aktuel:
#!/usr/bin/python3 import sys import paho.mqtt.client as mqtt import ssl # set the variables # Path to the Sensor systempath # 28-01142f7ba71a has to be changed to you sensor path! sensor = '/sys/bus/w1/devices/28-3c01f096929e/w1_slave' broker='192.168.178.185' port=1879 publish_topic="house/pi-ds18b20" clientid='python-mqtt-ds18b20' username='Tom' password='Atomameise' insecure=True qos=1 retain_message=True # do the stuff def readTempSensor(sensorName) : f = open(sensorName, 'r') lines = f.readlines() f.close() return lines def readTempLines(sensorName) : lines = readTempSensor(sensorName) while lines[0].strip()[-3:] != 'YES': time.sleep(0.2) lines = readTempSensor(sensorName) temperaturStr = lines[1].find('t=') if temperaturStr != -1 : tempData = lines[1][temperaturStr+2:] tempCelsius = float(tempData) / 1000.0 tempKelvin = 273 + float(tempData) / 1000 tempFahrenheit = float(tempData) / 1000 * 9.0 / 5.0 + 32.0 return [tempCelsius, tempKelvin, tempFahrenheit] #MQTT Connection client=mqtt.Client(clientid) client.username_pw_set(username, password) client.tls_set(cert_reqs=ssl.CERT_NONE) #no client certificate needed client.tls_insecure_set(insecure) client.connect(broker, port) client.loop_start() client.publish("{}/temperature".format(publish_topic),"{:.2f}".format(readTempLines(sensor)[0]),qos,retain_message) client.disconnect() client.loop_stop()
Mfg
-
RE: [Gelöst] MQTT-Verbindung via Python script
Ich kann Dir nicht mehr sagen.
Wenn ich wüsste was falsch ist, würde ich hier nicht fragen. -
RE: [Gelöst] MQTT-Verbindung via Python script
Wen meinst Du?
MQTT Adapter? läuft in IoBroker unter 192.168.178.185 -
RE: [Gelöst] MQTT-Verbindung via Python script
Da bin ich wieder...
Das Python script soll senden (temperatur) an IoBroker MQTT
Ich bin auch schon ein Stück weiter...
das script versucht zu senden, kommt aber nicht durch...!
#!/usr/bin/python3 import sys import paho.mqtt.client as mqtt import ssl # set the variables # Path to the Sensor systempath # 28-01142f7ba71a has to be changed to you sensor path! sensor = '/sys/bus/w1/devices/28-3c01f096929e/w1_slave' broker='FQDN / 192.168.178.185' port=1879 publish_topic="house/pi-ds18b20" clientid='python-mqtt-ds18b20' username='Tom' password='xxxxxxxxxx' insecure=True qos=1 retain_message=True # do the stuff def readTempSensor(sensorName) : f = open(sensorName, 'r') lines = f.readlines() f.close() return lines def readTempLines(sensorName) : lines = readTempSensor(sensorName) while lines[0].strip()[-3:] != 'YES': time.sleep(0.2) lines = readTempSensor(sensorName) temperaturStr = lines[1].find('t=') if temperaturStr != -1 : tempData = lines[1][temperaturStr+2:] tempCelsius = float(tempData) / 1000.0 tempKelvin = 273 + float(tempData) / 1000 tempFahrenheit = float(tempData) / 1000 * 9.0 / 5.0 + 32.0 return [tempCelsius, tempKelvin, tempFahrenheit] #MQTT Connection client=mqtt.Client(clientid) client.username_pw_set(username, password) client.tls_set(cert_reqs=ssl.CERT_NONE) #no client certificate needed client.tls_insecure_set(insecure) client.connect(broker, port) client.loop_start() client.publish("{}/temperature".format(publish_topic),"{:.2f}".format(readTempLines(sensor)[0]),qos,retain_message) client.disconnect() client.loop_stop()
Mfg
-
RE: [Gelöst] MQTT-Verbindung via Python script
@homoran sagte in MQTT-Verbindung:
welche MQTT Topologie nutzst du?
Da denke ich mal, dass es PUSH/SUBSCRIBE-Topologie ist.
Watermeter läuft bereits.