Ankündigung: NUT - Network UPS Tools

Begonnen von Creideiki, 18 September 2014, 14:32:38

Vorheriges Thema - Nächstes Thema

Burny4600

@fruit

Und wie hilft mir das weiter?

Gibt es sonst ein Möglichkeit eine USB mit dem Raspberry und FHEM zu betreiben?
LG Chris

Raspberry Pi 2-5, Bullseye Lite, Bookworm Lite
Schnittstellen: 1-Wire, FHEM2FEHEM, HM-MOD-UART, LAN, Modbus, MQTT, nanoCUL, RFXtrx433E, SIGNALduino, ser2net
Devices: APC, Eastron, FS20, IT, Homematic, MQTT, PV-(DEYE, EPEVER, FRONIUS), Resol-VBUS, S.USV, TEK603, WMR200, YouLess

Mitch

Hallo Zusammen,

sehr interessant das Thema!!

Ich würde gerne folgendes machen und fragen ob das so funktioniert:

USV hängt an Synology NAS, dort läuft der NUT Server.
Nun möchte ich, dass FHEM auf einen Stromausfall reagiert und noch ein paar Dinge einstellt (z.B. Temp auf bestimmten Wert) und dann den Server (auf dem FHEM läuft, ein Ubuntu Server) runter fährt.

Geht das so?
Was brauche ich noch auf meinen Ubuntu-Server? NUT Client?
Wer fährt den Server runter, FHEM oder NUT-Client?

Vielen Dank!
FHEM im Proxmox Container

fruit

@Burny4600

I am not sure it helps much at all - except that starting nut-server under raspbian jessie seems to be broken

It was working very well under wheezy, with the Cubietruck as a nut-client and it would shutdown along with fhem as expected.


The script you posted seems to be the sysvinit script from /etc/init.d

I believe this is now replaced by systemd - unless you are still running wheezy or have disabled systemd - I am not sure what raspbian version you have
Feel free to follow up in German if you prefer

Burny4600

#93
@Mitch
Soweit ich das beurteilen kann ist FHEM nur ein Monitor und weniger als ein NUT-Client.

Aber man kann mit diesen aufgenommenen Ereignissen trotzdem andere Komponeten bedienen, nur halt nicht die USV selbst über den NUT-Server.
Auf dem Server brauchst du eigentlich nichts mehr, denn da hast du ja den NUT-Server der die USV und den Server ja herunterfährt wenn es notwenig ist.

@fruit
Ich verwende die Version 2015-11-21-raspbian-jessie auf meinen Raspberry

Zudem ist es ärgerlich, sowie der NUT-Server fertig eingerichtet wurde funktioniert der FHEM Service auch nicht mehr.
LG Chris

Raspberry Pi 2-5, Bullseye Lite, Bookworm Lite
Schnittstellen: 1-Wire, FHEM2FEHEM, HM-MOD-UART, LAN, Modbus, MQTT, nanoCUL, RFXtrx433E, SIGNALduino, ser2net
Devices: APC, Eastron, FS20, IT, Homematic, MQTT, PV-(DEYE, EPEVER, FRONIUS), Resol-VBUS, S.USV, TEK603, WMR200, YouLess

Mitch

Danke Chris.

Also würde ich folgendes machen:
- NUT Server auf Synology aktivieren (mahr braucht es da nicht)
- im FHEM einen notify auf ein passendes Reading (z.B. Strom weg), welcher die Temp einstellt
- im NUT Client (auf FHEM Server) den Shutdown durchführen lassen

Kann die Fritte auch NUT Client spielen?
FHEM im Proxmox Container

fruit

In my hurry I had missed setting my static IP address in /etc/dhcpcd.conf on the new Pi2

nut-server would not start because it was waiting for IPs to come up with dhcp :(
All is good now

The fhem NUT module is working here - except if I reboot the Pi the module seems to be blocking and I have to restart
The nut-client on Cubietruck does reconnect with no problem.

I am sure it was OK before so perhaps another config issue here.
Feel free to follow up in German if you prefer

Burny4600

Wo genau wurde die Änderungen für DHCP bzw. der IP Adresse durchgeführt.


# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname
LG Chris

Raspberry Pi 2-5, Bullseye Lite, Bookworm Lite
Schnittstellen: 1-Wire, FHEM2FEHEM, HM-MOD-UART, LAN, Modbus, MQTT, nanoCUL, RFXtrx433E, SIGNALduino, ser2net
Devices: APC, Eastron, FS20, IT, Homematic, MQTT, PV-(DEYE, EPEVER, FRONIUS), Resol-VBUS, S.USV, TEK603, WMR200, YouLess

fruit

In wheezy IP address was set in /etc/network/nterfaces.
For jessie it should be set in /etc/dhcpsd.conf

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
#etc
#etc
# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

interface eth0
static ip_address=192.168.1.35
static routers=192.168.1.33
static domain_name_servers=192.168.1.33

## interface wlan0
## static ip_address=192.168.1.201/24
## static routers=192.168.1.1
## static domain_name_servers=192.168.1.1

I only have eth0, uncomment/edot wlan0 if you have wlan
Feel free to follow up in German if you prefer

Burny4600

#98
Das war es noch nicht.
Nach wie vor das gleiche.

Habe in der interfaces Datei noch folgendes entdeckt wo ich aber nicht weiß wo ich die Einstellungen vornehmen kann.
Nähmlich wo ich "man dhcpcd.conf" finde.
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf


Ohne diese Änderung habe ich den NUT-Server jetzt zumindest zum Laufen gebracht.
Unter raspi-config => 3 Wait for Network Boot => muß folgendes eingestellt werden damit der NUT-Server es mitbekommt.
Slow Wait for Network connection befor completing boot.
Das verhält sich anscheinend ähnlich wie der Start ohne DHCP, da der Raspy wartet bis er die vollständigen Netzwerk Informationen erhalten hat.
Jetzt besteht leider nur noch das Problem das die NUT-Installation den FHEM Dienst killt.
Die NUT Dienste sind es jedenfalls nicht, da wenn ich alle NUT-Dienste deaktiviere und einen Reboot ausführe der FHEM Dienst zwar läuft aber ich keinen Zugriff auf FHEM habe.
LG Chris

Raspberry Pi 2-5, Bullseye Lite, Bookworm Lite
Schnittstellen: 1-Wire, FHEM2FEHEM, HM-MOD-UART, LAN, Modbus, MQTT, nanoCUL, RFXtrx433E, SIGNALduino, ser2net
Devices: APC, Eastron, FS20, IT, Homematic, MQTT, PV-(DEYE, EPEVER, FRONIUS), Resol-VBUS, S.USV, TEK603, WMR200, YouLess

fruit

I have exactly the same /etc/network/interfaces as yours

Google is not helping :(

I think you are asking for 'man dhcpcd. conf' as you posted /etc/dhcpcd.conf earlier

apropos dhcpcd
apropos is useful :)
man dhcpcd.conf
Posting all of /var/log/syslog at boot is a lot so I will try and list important lines to show the order in which they happen here

Dec 21 10:35:33 rpi systemd[1]: Starting Internet superserver...
Dec 21 10:35:33 rpi systemd[1]: Started Internet superserver.
Dec 21 10:35:33 rpi systemd[1]: Starting dhcpcd on all interfaces...
..
Dec 21 10:35:33 rpi dhcpcd[493]: DUID 00:01:00:01:1d:96:d4:2c:b8:27:eb:90:f1:c5
Dec 21 10:35:33 rpi dhcpcd[493]: eth0: IAID eb:69:1b:86
Dec 21 10:35:33 rpi CRON[515]: (root) CMD (/bin/sleep 900; /usr/bin/touch /opt/fhem/log/fhem.save; /etc/init.d/watchdog start)
Dec 21 10:35:33 rpi CRON[516]: (logcheck) CMD (   if [ -x /usr/sbin/logcheck ]; then nice -n10 /usr/sbin/logcheck -R; fi)
Dec 21 10:35:33 rpi dhcpcd[493]: eth0: soliciting an IPv6 router
Dec 21 10:35:33 rpi dhcpcd[493]: eth0: using static address 192.87.182.35/8
Dec 21 10:35:33 rpi dhcpcd[493]: eth0: adding route to 192.0.0.0/8
Dec 21 10:35:33 rpi dhcpcd[493]: eth0: adding default route via 192.87.182.33
..
Dec 21 10:35:33 rpi systemd[1]: Starting Network.
Dec 21 10:35:33 rpi systemd[1]: Reached target Network.
..
Dec 21 10:35:33 rpi avahi-daemon[437]: New relevant interface eth0.IPv6 for mDNS.
Dec 21 10:35:33 rpi avahi-daemon[437]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.87.182.35.
Dec 21 10:35:33 rpi avahi-daemon[437]: New relevant interface eth0.IPv4 for mDNS.
Dec 21 10:35:33 rpi avahi-daemon[437]: Network interface enumeration completed.
Dec 21 10:35:33 rpi avahi-daemon[437]: Registering new address record for 2001:8b0:111b:0:ba27:ebff:fe69:1b86 on eth0.*.
Dec 21 10:35:33 rpi avahi-daemon[437]: Registering new address record for 192.87.182.35 on eth0.IPv4.
..
Dec 21 10:35:33 rpi systemd[1]: Starting /etc/rc.local Compatibility...
Dec 21 10:35:33 rpi systemd[1]: Starting Network is Online.
..
Dec 21 10:35:33 rpi upsdrvctl[559]: Using subdriver: APC HID 0.95
Dec 21 10:35:33 rpi upsdrvctl[559]: Network UPS Tools - Generic HID driver 0.38 (2.7.2)
Dec 21 10:35:33 rpi upsdrvctl[559]: USB communication driver 0.32
..
Dec 21 10:35:33 rpi upsdrvctl[559]: Network UPS Tools - UPS driver controller 2.7.2
Dec 21 10:35:33 rpi systemd[1]: Started Network UPS Tools - power device driver controller.
Dec 21 10:35:33 rpi systemd[1]: Starting Network UPS Tools - power devices information server...
Dec 21 10:35:33 rpi upsd[738]: fopen /var/run/nut/upsd.pid: No such file or directory
Dec 21 10:35:33 rpi upsd[738]: listening on 192.87.182.35 port 3493
Dec 21 10:35:33 rpi upsd[738]: listening on 192.87.182.35 port 3493
Dec 21 10:35:33 rpi upsd[738]: listening on 127.0.0.1 port 3493
Dec 21 10:35:33 rpi upsd[738]: Connected to UPS [Smart-UPS750]: usbhid-ups-Smart-UPS750
Dec 21 10:35:33 rpi upsd[738]: listening on 127.0.0.1 port 3493
Dec 21 10:35:33 rpi upsd[738]: Connected to UPS [Smart-UPS750]: usbhid-ups-Smart-UPS750
Dec 21 10:35:34 rpi upsd[749]: Startup successful


It is possible the Wait for Network Boot is causing problems but I believe it should pause boot until hhe network is up
Feel free to follow up in German if you prefer

Burny4600

#100
Habe jetzt beide Fehler gefunden.  :P

Folgende Erkenntnisse:
Bei der NUT Installation ist darauf zu achten das folgender Eintrag in der fhem.cfg deaktiviert werden muß.
# define initialUsbCheck notify global:INITIALIZED usb create
Wenn dieser Eintrag aktiv ist stört das die USV die local am USB Anschluß angeschlossen ist.
Hat man den Watchdog auch noch aktiviert funktioniert der FHEM Dienst nicht mehr.

Damit die locale USV überwacht werden kann und der Watchdog funktioniert ist lediglich auf diesen Eintrag zu achten.

Boot Problem mit NUT und Raspberry:
Damit der NUT-Server Dienst wirklich startet ist entweder die Netzwerkadresse manuell einzugeben, oder was ich für das sinnvollste halte folgenden Eintrag zu ändern.
Unter raspi-config => 3 Wait for Network Boot => muß folgendes eingestellt werden damit der NUT-Server es mitbekommt.
=> Slow Wait for Network connection befor completing boot.

Somit laufen jetzt bei mir der NUT-Server und FHEM nach einem reboot.  ;)

Schwere Geburt, aber ich wieder ein Stückchen geschafft. :D

@fruit
Danke für deinen Tipp.
Ohne diesen Tipp hätte ich wahrscheinlich noch lange gesucht.
LG Chris

Raspberry Pi 2-5, Bullseye Lite, Bookworm Lite
Schnittstellen: 1-Wire, FHEM2FEHEM, HM-MOD-UART, LAN, Modbus, MQTT, nanoCUL, RFXtrx433E, SIGNALduino, ser2net
Devices: APC, Eastron, FS20, IT, Homematic, MQTT, PV-(DEYE, EPEVER, FRONIUS), Resol-VBUS, S.USV, TEK603, WMR200, YouLess

fruit

I am pleased you have it running
It is always the small things that are most difficult to find :(
Feel free to follow up in German if you prefer

Burny4600

#102
Nächstes Problem:
FHEM NUT will mit der angeschlossen USV nicht arbeiten.

Habe folgende Einträge im LOG:
2015.12.21 18:47:41 3: Opening USV device 192.168.17.233:3493
2015.12.21 18:47:41 3: USV device opened
2015.12.21 18:47:41 1: Including /opt/fhem/log/fhem.save
2015.12.21 18:47:41 0: Featurelevel: 5.7
2015.12.21 18:47:41 0: Server started with 10 defined entities (fhem.pl:10208/2015-12-19 perl:5.020002 os:linux user:fhem pid:1174)
2015.12.21 18:47:41 5: NUT RX: ERR UNKNOWN-UPS
2015.12.21 18:47:41 2: NUT Error: UNKNOWN-UPS
2015.12.21 18:47:51 5: NUT polling disabled.
2015.12.21 18:48:01 5: NUT polling disabled.
2015.12.21 18:48:11 5: NUT polling disabled.
2015.12.21 18:48:21 5: NUT polling disabled.
2015.12.21 18:48:31 5: NUT polling disabled.
2015.12.21 18:48:41 5: NUT polling disabled.
2015.12.21 18:48:42 1: 192.168.17.233:3493 disconnected, waiting to reappear (USV)
2015.12.21 18:48:47 1: 192.168.17.233:3493 reappeared (USV)
2015.12.21 18:48:47 5: NUT polling disabled.
2015.12.21 18:48:57 5: NUT polling disabled.
2015.12.21 18:49:07 5: NUT polling disabled.
2015.12.21 18:49:17 5: NUT polling disabled.
2015.12.21 18:49:27 5: NUT polling disabled.
2015.12.21 18:49:37 5: NUT polling disabled.
2015.12.21 18:49:47 5: NUT polling disabled.
2015.12.21 18:49:49 1: 192.168.17.233:3493 disconnected, waiting to reappear (USV)
2015.12.21 18:49:54 1: 192.168.17.233:3493 reappeared (USV)
2015.12.21 18:49:54 5: NUT polling disabled.
2015.12.21 18:50:04 5: NUT polling disabled.


upsc apc1500va spuckt folgendes für die angeschlossene USV aus.

Init SSL without certificate database
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 50
battery.mfr.date: 2010/08/20
battery.runtime: 20100
battery.runtime.low: 120
battery.temperature: 2493.9
battery.type: PbAc
battery.voltage: 122.1
battery.voltage.nominal: 24.0
device.mfr: American Power Conversion
device.model: Smart-UPS 1500
device.serial: AS0349330598
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.version: 2.7.2
driver.version.data: APC HID 0.95
driver.version.internal: 0.38
input.sensitivity: high
input.transfer.high: 253
input.transfer.low: 208
input.voltage: 234.7
output.frequency: 50.0
output.voltage: 233.2
output.voltage.nominal: 230.0
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.firmware: 601.3.I
ups.firmware.aux: 1.5
ups.load: 0.0
ups.mfr: American Power Conversion
ups.mfr.date: 2003/12/03
ups.model: Smart-UPS 1500
ups.productid: 0002
ups.serial: AS0349330598
ups.status: OL RB
ups.test.result: No test initiated
ups.timer.reboot: -1
ups.timer.shutdown: -1
ups.timer.start: -1
ups.vendorid: 051d


Definition im fhem.cfg sieht so aus.
define USV NUT usbhid-ups 192.168.17.233
attr USV asReadings battery.charge,battery.runtime,input.voltage,ups.load
attr USV disable 1
attr USV pollState 10
attr USV pollVal 60
attr USV verbose 5


Die USV ist lokal am Raspberry angeschlossen wo auch das FHEM läuft.
Ist für diesen Fall noch ein zusätzliche Änderung notwendig?
LG Chris

Raspberry Pi 2-5, Bullseye Lite, Bookworm Lite
Schnittstellen: 1-Wire, FHEM2FEHEM, HM-MOD-UART, LAN, Modbus, MQTT, nanoCUL, RFXtrx433E, SIGNALduino, ser2net
Devices: APC, Eastron, FS20, IT, Homematic, MQTT, PV-(DEYE, EPEVER, FRONIUS), Resol-VBUS, S.USV, TEK603, WMR200, YouLess

fruit

attr USV disable 1
=
NUT polling disabled.

Try with

attr USV disable 0

unless I have missed a reason for you setting disabled.
Feel free to follow up in German if you prefer

Burny4600

Polling geändert.

Aber die USV wird nicht erkannt?

Alles ist aber aktuell. Mit heutigem Datum nochmals alles aktualisiert.
LG Chris

Raspberry Pi 2-5, Bullseye Lite, Bookworm Lite
Schnittstellen: 1-Wire, FHEM2FEHEM, HM-MOD-UART, LAN, Modbus, MQTT, nanoCUL, RFXtrx433E, SIGNALduino, ser2net
Devices: APC, Eastron, FS20, IT, Homematic, MQTT, PV-(DEYE, EPEVER, FRONIUS), Resol-VBUS, S.USV, TEK603, WMR200, YouLess