Folgende Warnungen sind aufgetreten:
Warning [2] Undefined variable $unreadreports - Line: 34 - File: global.php(961) : eval()'d code PHP 8.2.2 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/global.php(961) : eval()'d code 34 errorHandler->error_callback
/global.php 961 eval
/showthread.php 28 require_once
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 43 - File: showthread.php(1621) : eval()'d code PHP 8.2.2 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1621) : eval()'d code 43 errorHandler->error_callback
/showthread.php 1621 eval




Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
USV PIco Status Anzeige.
#1
Hallo Zusammen

Leider bin ich mit meinem Problem immer noch nicht weiter und eröffne mal ein neues Thema in der Hoffnung, dass mir jemand weiter helfen kann.

Ich habe eine PIco USV von  pimodules.com im Einsatz und kann im Terminal mit einem python script  und dem Befehl sudo python pico_status.py mir den aktuellen Status der USV anzeigen lassen.

Leider bin ich weder Programmierer noch Kodi Spezialist. Ich möchte nun einen Button oder ähnliches im Skin einbauen welcher mir mit Hilfe des scripts den Status der USV im Kodi anzeigt. Es muss nicht konstant angezeigt werden einfach als Info welche abgerufen wird. Ich habe mich auch schon mit Google und co versucht bin aber auf keinen grünen zweig gekommen od. einfach unfähig es zu verstehen Smile

Gruss Mark
Raspberry Pi 2 , Pollin 7" Display, PIco USV, Jessie Image
Am Testen Raspberry Pi 3, 7" Orginal Display, Jessie Image
Zitieren
#2
Poste mal was die Shell ausgibt wenn du den Status mit dem Script ausgeben lässt.
CarPi: RPi 3 mit 7" RPi Touchscreen & PiUSV+, Jessie, Kodi 15.2
Testing: Raspbian Jessie mit Kodi 15.2 - Step by Step
Projekte: SmartHome, Ambilight
Zitieren
#3
Hi Christian wie gewünscht:

#!/usr/bin/python
# -*- coding: utf-8 -*-
# improved and completed by PiModules Version 1.0 29.08.2015
# picoStatus-v3.py by KTB is based on upisStatus.py by Kyriakos Naziris
# Kyriakos Naziris / University of Portsmouth / kyriakos@naziris.co.uk


import smbus
import time
import datetime

# You can install psutil using: sudo pip install psutil
#import psutil

i2c = smbus.SMBus(1)

def pwr_mode():
data = i2c.read_byte_data(0x69, 0x00)
data = data & ~(1 << 7)
if (data == 1):
return "RPi"
elif (data == 2):
return "BAT"
else:
return "ERR"

def bat_level():
time.sleep(0.1)
data = i2c.read_word_data(0x69, 0x01)
data = format(data,"02x")
return (float(data) / 100)

def rpi_level():
time.sleep(0.1)
data = i2c.read_word_data(0x69, 0x03)
data = format(data,"02x")
return (float(data) / 100)

def fw_version():
time.sleep(0.1)
data = i2c.read_byte_data(0x6b, 0x00)
data = format(data,"02x")
return data

def sot23_temp():
time.sleep(0.1)
data = i2c.read_byte_data(0x69, 0x0C)
data = format(data,"02x")
return data

def to92_temp():
time.sleep(0.1)
data = i2c.read_byte_data(0x69, 0x0d)
data = format(data,"02x")
return data

def ad1_read():
time.sleep(0.1)
data = i2c.read_word_data(0x69, 0x05)
data = format(data,"02x")
return (float(data) / 100)

def ad2_read():
time.sleep(0.1)
data = i2c.read_word_data(0x69, 0x07)
data = format(data,"02x")
return (float(data) / 100)

print " "
print " pico status V1.0"
print "***********************************"
print " ","UPS PIco Firmware:",fw_version()
print " ","Powering Mode:",pwr_mode()
print " ","BAT Volatge:", bat_level(),"V"
print " ","RPi Voltage:" , rpi_level(),"V"
print " ","SOT23 Temperature:" , sot23_temp(),"C"
print " ","TO-92 Temperature:" , to92_temp(),"C"
print " ","A/D1 Voltage:" , ad1_read(),"V"
print " ","A/D2 Voltage:" , ad2_read(),"V"
print "***********************************"
print " "
Raspberry Pi 2 , Pollin 7" Display, PIco USV, Jessie Image
Am Testen Raspberry Pi 3, 7" Orginal Display, Jessie Image
Zitieren
#4
Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import os
import xbmc


def set_kodi_prop(property, value, id=10000):
    xbmc.executebuiltin('SetProperty(%s,%s,%s)' % (property, value, id))


def main():
    os.system("sudo service piupsmon status > piupsmon_status.txt")

    with open('piupsmon_status.txt') as f:
        value = f.readlines()
        words = value[2].split()
        status = words[1]
        set_kodi_prop('piupsmonstatus', status)


if __name__ == '__main__':
    main()

kombiniert das einfach, ohne zwischenschritt über txt.
und gebt die werte in einer liste aus, dann is keine skin notwendig.

hier mein angefangenes addon


Angehängte Dateien
.zip   service.ups_pico_beta.zip (Größe: 41,06 KB / Downloads: 12)
Zitieren
#5
Vielen dank

Ich versuch mal daraus was zu machen, bin aber wie gesagt ohne jegliche Erfahrung was das Programmieren angeht.
Raspberry Pi 2 , Pollin 7" Display, PIco USV, Jessie Image
Am Testen Raspberry Pi 3, 7" Orginal Display, Jessie Image
Zitieren
#6
die log funktion müsste umgeschrieben werden, da print in kodi 16 nur noch in debug mode ins logfile eingetragen wird.
Zitieren
#7
Danke für den tipp habe noch kodi 15 installiert

Gesendet von meinem SM-G935F mit Tapatalk
Raspberry Pi 2 , Pollin 7" Display, PIco USV, Jessie Image
Am Testen Raspberry Pi 3, 7" Orginal Display, Jessie Image
Zitieren
#8
Hallo zusammen. Ich habs leider nicht geschafft das ganze ins kodi zu impementieren. Addon konnte ichbinstallieren danke an harryberlin leider klapier ich das mit dem zusammmen stellen und auslesen nicht. Es fehlt mir einfach am Wissen auch nach 5h im netz rumgurken. Ich lege das ganze mal auf Eis. Falls sich jemand doch die Zeit nehmen möchte und mir das ganze auf die Beine stellt bin ich sehr dankbar dafür

Gesendet von meinem SM-G935F mit Tapatalk
Raspberry Pi 2 , Pollin 7" Display, PIco USV, Jessie Image
Am Testen Raspberry Pi 3, 7" Orginal Display, Jessie Image
Zitieren
#9
Da ich bei der PIUSV+ nicht so wirklich viel rausbekomme prüfe ich nur den Status des Daemon und lasse mir das Live auf dem Homescreen in Kodi anzeigen.
CarPi: RPi 3 mit 7" RPi Touchscreen & PiUSV+, Jessie, Kodi 15.2
Testing: Raspbian Jessie mit Kodi 15.2 - Step by Step
Projekte: SmartHome, Ambilight
Zitieren
#10
teste das mal in der console.
wenn es läuft, kannst dich wieder melden.


Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# improved and completed by PiModules Version 1.0 29.08.2015
# picoStatus-v3.py by KTB is based on upisStatus.py by Kyriakos Naziris
# Kyriakos Naziris / University of Portsmouth / kyriakos@naziris.co.uk


import sys
import os
# import xbmc
import smbus
import time
import datetime


# You can install psutil using: sudo pip install psutil
# import psutil


def set_kodi_prop(property, value, id=10000):
   xbmc.executebuiltin('SetProperty(%s,%s,%s)' % (property, value, id))


def year():
   return i2c.read_byte_data(0x6A, 0x06)[1][2:]


def month():
   return i2c.read_byte_data(0x6A, 0x05)[1][2:]


def day():
   return i2c.read_byte_data(0x6A, 0x04)[1][2:]


def day_of_week():
   days_of_the_week = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
   dow = i2c.read_byte_data(0x6A, 0x03)
   return days_of_the_week[int(dow[1][3:]) - 1]


def hour():
   return i2c.read_byte_data(0x6A, 0x02)[1][2:]


def minute():
   return i2c.read_byte_data(0x6A, 0x01)[1][2:]


def seconds():
   return i2c.read_byte_data(0x6A, 0x00)[1][2:]


def ccf():
   return i2c.read_byte_data(0x6A, 0x07)[1][2:]


def pwr_mode():
   data = i2c.read_byte_data(0x69, 0x00)
   data = data & ~(1 << 7)
   if (data == 1):
       return "RPi"
   elif (data == 2):
       return "BAT"
   else:
       return "ERR"


def bat_level_2():
   time.sleep(0.1)
   data = i2c.read_word_data(0x69, 0x01)
   data = format(data, "02x")
   return (float(data) / 100)


def bat_level_1():
   time.sleep(0.1)
   data = i2c.read_word_data(0x69, 0x02)
   data = format(data, "02x")
   return (float(data) / 100)


def rpi_level_2():
   time.sleep(0.1)
   data = i2c.read_word_data(0x69, 0x03)
   data = format(data, "02x")
   return (float(data) / 100)


def rpi_level_1():
   time.sleep(0.1)
   data = i2c.read_word_data(0x69, 0x04)
   data = format(data, "02x")
   return (float(data) / 100)


def ad1_read():
   time.sleep(0.1)
   data = i2c.read_word_data(0x69, 0x05)
   data = format(data, "02x")
   return (float(data) / 100)


def ad2_read():
   time.sleep(0.1)
   data = i2c.read_word_data(0x69, 0x07)
   data = format(data, "02x")
   return (float(data) / 100)


def temp_celsius():
   return i2c.read_word_data(0x69, 0x12)


def sot23_temp():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x69, 0x0C)
   data = format(data, "02x")
   return data


def to92_temp():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x69, 0x0d)
   data = format(data, "02x")
   return data


def fw_version():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x00)
   data = format(data, "02x")
   return data


def error_code():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x01)
   data = format(data, "02x")
   return data


def rpi_serror_2():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x02)
   data = format(data, "02x")
   return data


def rpi_serror_1():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x03)
   data = format(data, "02x")
   return data


def bat_serror_2():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x04)
   data = format(data, "02x")
   return data


def bat_serror_1():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x05)
   data = format(data, "02x")
   return data


def tmp_serror_2():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x07)
   data = format(data, "02x")
   return data


def tmp_serror_1():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x06)
   data = format(data, "02x")
   return data


def sta_counter():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x08)
   data = format(data, "02x")
   return data


def fssd_batime():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x09)
   data = format(data, "02x")
   return data


def lprsta():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x10)
   data = format(data, "02x")
   return data


def btto():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x11)
   data = format(data, "02x")
   return data


def led_blue():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x12)
   data = format(data, "02x")
   return data


def led_red():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x13)
   data = format(data, "02x")
   return data


def buzmode():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x14)
   data = format(data, "02x")
   return data


def fanmode():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x15)
   data = format(data, "02x")
   return data


def fanspeed():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x16)
   data = format(data, "02x")
   return data


def picoxbmc():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x23)
   data = format(data, "02x")
   return data


def fssd_tout():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x23)
   data = format(data, "02x")
   return data


def main():
   status = ['OFF', 'ON']
   buz_fan_modes = ['Disabled', 'Enabled', 'Automatic']
   fan_speeds = ['0', '100', '25', '50', '75']
   
   print " "
   print " pico status V1.0"
   print "***********************************"
   print " ", "UPS PIco Firmware:", fw_version()
   print " ", "Powering Mode:", pwr_mode()
   print " ", "BAT Volatge:", bat_level(), "V"
   print " ", "RPi Voltage:", rpi_level(), "V"
   print " ", "SOT23 Temperature:", sot23_temp(), "C"
   print " ", "TO-92 Temperature:", to92_temp(), "C"
   print " ", "A/D1 Voltage:", ad1_read(), "V"
   print " ", "A/D2 Voltage:", ad2_read(), "V"
   print "***********************************"
   print " "

   print "--- RTC data ---"
   print year() + "-" + month() + "-" + day() + " " + day_of_week() + " " + hour() + ":" + minute() + ":" + seconds() + " /" + ccf()
   print "--- Status registers ---   "
   print "Mode\t\tBat_lvl\t\tRPi_lvl\t\tTemp"
   print '%s \t\t %s \t\t %s \t\t %s' % (pwr_mode(), bat_level_1(), rpi_level_2(), temp_celsius())
   print "--- Status commands ---"
   print "Firmware: %s" % fw_version()
   print "Error code: %s" % '{0:08b}'.format(int(error_code()[1][2:]))
   print "rpi_serror: %s" % rpi_serror_1()[1][3:] + "." + rpi_serror_2()[1][2:] + " V"
   print "bat_serror: %s" % bat_serror_1()[1][3:] + "." + bat_serror_2()[1][2:] + " V"
   print "tmp_serror: %s" % tmp_serror_1()[1][2:] + "." + tmp_serror_2()[1][2:] + " " + unichr(176) + "C"
   print "Still Alive Timeout Counter: %d s (255=disabled)" % int(sta_counter()[1], 16)
   print "Battery Running Time: %d s (255=disabled)" % int(fssd_batime()[1], 16)
   print "Low Power Restart Time: %d s" % int(lprsta()[1], 16)
   print "Battery Powering Testing Timeout: %d s" % int(btto()[1], 16)
   print "led_blue: %s" % status[int(led_blue()[1][3:])]
   print "led_red: %s" % status[int(led_red()[1][3:])]
   print "Integrated Buzzer Mode: %s" % buz_fan_modes[int(buzmode()[1][3:])]
   print "Integrated Fan Mode: %s" % buz_fan_modes[int(fanmode()[1][3:])]
   print "Integrated Fan Speed: %s %%" % fan_speeds[int(fanspeed()[1][3:])]
   print "XBMC Mode: %s" % status[int(picoxbmc()[1][3:])]
   print "FSSD Timeout: %d s" % int(fssd_tout()[1], 16)


i2c = smbus.SMBus(1)

if __name__ == '__main__':
   main()
Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste
RasPiCarProjekt