openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.57k forks source link

[SystemInfo] Battery at 0 #1471

Closed DaAwesomeP closed 7 years ago

DaAwesomeP commented 7 years ago

I'm on a relatively old laptop running Debian 8.6.0 32-bit headless and OH2 beta. Running cat /sys/class/power_supply/BAT0/capacity gives me 98, but the SystemInfo binding always gives me 0.0. Are then any options or packages that I'm missing? I am running headless, so I'm possibly missing some monitoring/GUI libraries or CLI tools. All of the other SystemInfo channels work fine.

svilenvul commented 7 years ago

Are then any options or packages that I'm missing?

No this should not be the case, no external packages are needed.

Running cat /sys/class/power_supply/BAT0/capacity gives me 98, but the SystemInfo binding always gives me 0.0

From what I see, oshi is reading the same file.

Do you use the latest version of the binding ?

ThomDietrich commented 7 years ago

0.0 seems like a fallback value after reading the actual battery capacity failed at some point in the chain. That should not happen. If reading fails the item should be NULL to indicate the error. @DaAwesomeP could you please post the related events.log lines? If there you see 0.0 as well, please search for related messages in openhab.log. At last you might want to increase the logging level of the systeminfo binding to DEBUG and try again.

DaAwesomeP commented 7 years ago

Do you use the latest version of the binding ?

@svilenvul I am using the latest binding-systeminfo - 2.0.0.SNAPSHOT as installed from PaperUI from OH2 snapshot, completely up to date via the Debian APT repo.

@DaAwesomeP could you please post the related events.log lines?

@ThomDietrich There is no trace of anything related to batt or battery in events.log or openhab.log.

At last you might want to increase the logging level of the systeminfo binding to DEBUG and try again.

How may I accomplish that?

ThomDietrich commented 7 years ago

Logging: http://docs.openhab.org/administration/logging.html

Is your item named "battery"? You need to grep for both the item name and the binding name to find logging info indicating or helping to find the problem.

DaAwesomeP commented 7 years ago

Is your item named "battery"? You need to grep for both the item name and the binding name to find logging info indicating or helping to find the problem.

I greped for both the name, binding name, and anything related to "batt" or "battery" and didn't find anything. I have cleared the logs several times, and I'm using persistence, so it's possible that it doesn't appear in the logs very often. I'll try the debug logging later today.

DaAwesomeP commented 7 years ago

OK, so I enabled debug logging on every possible option in /var/lib/openhab2/etc/org.ops4j.logging.cfg. events.log:

[ItemChannelLinkAddedEvent ] - Link 'System_IP-systeminfo:computer:serv1:network#ip' has been added.
[ItemChannelLinkAddedEvent ] - Link 'System_Mem_AvailablePercent-systeminfo:computer:serv1:memory#availablePercent' has been added.
[ItemChannelLinkAddedEvent ] - Link 'System_Swap_AvailablePercent-systeminfo:computer:serv1:swap#availablePercent' has been added.
[ItemChannelLinkAddedEvent ] - Link 'System_Stor_AvailablePercent-systeminfo:computer:serv1:storage#availablePercent' has been added.
[ItemChannelLinkAddedEvent ] - Link 'System_CPU_Load-systeminfo:computer:serv1:cpu#load' has been added.
[ItemChannelLinkAddedEvent ] - Link 'System_CPU_Uptime-systeminfo:computer:serv1:cpu#uptime' has been added.
[ItemChannelLinkAddedEvent ] - Link 'System_CPU_Temp-systeminfo:computer:serv1:sensors#cpuTemp' has been added.
[ItemChannelLinkAddedEvent ] - Link 'System_Batt_RemainingCapacity-systeminfo:computer:serv1:battery#remainingCapacity' has been added.
[ThingAddedEvent           ] - Thing 'systeminfo:computer:serv1' has been added.
[ThingStatusInfoEvent      ] - 'systeminfo:computer:serv1' updated: INITIALIZING
[hingStatusInfoChangedEvent] - 'systeminfo:computer:serv1' changed from UNINITIALIZED to INITIALIZING
[ThingStatusInfoEvent      ] - 'systeminfo:computer:serv1' updated: ONLINE
[hingStatusInfoChangedEvent] - 'systeminfo:computer:serv1' changed from INITIALIZING to ONLINE

openhab.log (grep "system\|batt")

[DEBUG] [org.apache.karaf.system.core        ] - BundleEvent STARTING - org.apache.karaf.system.core
[DEBUG] [org.apache.karaf.system.core        ] - ServiceEvent REGISTERED - {org.apache.karaf.system.SystemService}={service.id=90, service.bundleid=56, service.scope=singleton} - org.apache.karaf.system.core
[DEBUG] [org.apache.karaf.system.core        ] - ServiceEvent REGISTERED - {org.apache.karaf.system.management.SystemMBean, javax.management.DynamicMBean, javax.management.MBeanRegistration}={jmx.objectname=org.apache.karaf:type=system,name=main, service.id=91, service.bundleid=56, service.scope=singleton} - org.apache.karaf.system.core
[DEBUG] [mpl.info.InfoBundleTrackerCustomizer] - Ignore incorrect info null provided by bundle org.apache.karaf.system.core
[INFO ] [g.apache.aries.spifly.dynamic.bundle] - Bundle Considered for SPI providers: org.apache.karaf.system.core
[INFO ] [g.apache.aries.spifly.dynamic.bundle] - No 'SPI-Provider' Manifest header. Skipping bundle: org.apache.karaf.system.core
[DEBUG] [org.apache.karaf.system.core        ] - BundleEvent STARTED - org.apache.karaf.system.core
[DEBUG] [org.eclipse.smarthome.core.audio    ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.audio.AudioManager, org.eclipse.smarthome.config.core.ConfigOptionProvider}={component.name=org.eclipse.smarthome.audio, defaultSource=javasound, service.config.category=system, service.config.description.uri=system:audio, felix.fileinstall.filename=file:/var/lib/openhab2/etc/org.eclipse.smarthome.audio.cfg, service.pid=org.eclipse.smarthome.audio, service.config.label=Audio, defaultSink=enhancedjavasound, component.id=4, service.id=106, service.bundleid=97, service.scope=bundle} - org.eclipse.smarthome.core.audio
[DEBUG] [ell.impl.action.osgi.CommandExtender] - org.apache.karaf.system.core (56): Starting extension synchronously
[INFO ] [ll.impl.action.osgi.CommandExtension] - Registering commands for bundle org.apache.karaf.system.core/4.0.4
[DEBUG] [org.eclipse.smarthome.core.voice    ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.voice.VoiceManager, org.eclipse.smarthome.config.core.ConfigOptionProvider}={component.name=org.eclipse.smarthome.voice, service.config.category=system, service.config.description.uri=system:voice, defaultHLI=rulehli, felix.fileinstall.filename=file:/var/lib/openhab2/etc/org.eclipse.smarthome.voice.cfg, service.pid=org.eclipse.smarthome.voice, defaultVoice=marytts:cmuslthsmm, service.config.label=Voice, component.id=2, defaultTTS=marytts, service.id=145, service.bundleid=106, service.scope=bundle} - org.eclipse.smarthome.core.voice
[DEBUG] [org.eclipse.smarthome.core          ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.i18n.LocaleProvider}={service.pid=org.eclipse.smarthome.core.localeprovider, service.config.category=system, service.config.label=Locale, component.name=org.eclipse.smarthome.core.localeprovider, region=US, component.id=31, language=en, service.config.description.uri=system:locale, service.id=144, service.bundleid=96, service.scope=bundle} - org.eclipse.smarthome.core
[DEBUG] [g.eclipse.smarthome.core.persistence] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.persistence.PersistenceServiceRegistry, org.eclipse.smarthome.config.core.ConfigOptionProvider}={service.pid=org.eclipse.smarthome.persistence, service.config.category=system, default=jdbc, service.config.label=Persistence, component.name=org.eclipse.smarthome.persistence, component.id=37, service.config.description.uri=system:persistence, service.id=157, service.bundleid=101, service.scope=bundle} - org.eclipse.smarthome.core.persistence
[INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'system.items'
[DEBUG] [el.item.internal.GenericItemProvider] - Processing binding configs for items from model 'system.items'
[DEBUG] [el.item.internal.GenericItemProvider] - Read items from model 'system.items'
[DEBUG] [el.item.internal.GenericItemProvider] - Read items from model 'system.items'
[DEBUG] [el.item.internal.GenericItemProvider] - Read items from model 'system.items'
[DEBUG] [el.item.internal.GenericItemProvider] - Start processing binding configuration of Item 'System_Batt_RemainingCapacity (Type=NumberItem, State=NULL, Label=Battery Remaining, Category=battery)' with 'GenericItemChannelLinkProvider' reader.
[DEBUG] [org.eclipse.smarthome.core.thing    ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.link.ThingLinkManager, org.eclipse.smarthome.core.events.EventSubscriber}={service.pid=org.eclipse.smarthome.links, service.config.category=system, service.config.label=Item Linking, autoLinks=false, component.name=org.eclipse.smarthome.links, felix.fileinstall.filename=file:/var/lib/openhab2/etc/org.eclipse.smarthome.links.cfg, component.id=55, service.config.description.uri=system:links, service.id=231, service.bundleid=103, service.scope=bundle} - org.eclipse.smarthome.core.thing
[DEBUG] [ome.core.thing.internal.ThingManager] - Thing 'systeminfo:computer:serv1' is tracked by ThingManager.
[DEBUG] [ome.core.thing.internal.ThingManager] - Not registering a handler at this point since no handler factory for thing 'systeminfo:computer:serv1' found.
[DEBUG] [org.openhab.core.karaf              ] - ServiceEvent REGISTERED - {org.openhab.core.karaf.internal.FeatureInstaller, org.osgi.service.cm.ConfigurationListener}={misc=restdocs, component.name=org.openhab.addons, remote=true, service.config.category=system, action=xbmc, service.config.description.uri=system:addons, felix.fileinstall.filename=file:/var/lib/openhab2/etc/org.openhab.addons.cfg, service.config.label=Extension Management, service.pid=org.openhab.addons, binding=astro,ntp,systeminfo,weather,exec,xbmc, ui=basic,paper,habpanel,habmin, persistence=jdbc-postgresql, component.id=129, voice=marytts, package=standard, legacy=true, service.id=249, service.bundleid=166, service.scope=bundle} - org.openhab.core.karaf
[DEBUG] [.impl.DefaultLocalRepositoryProvider] - Using manager SimpleLocalRepositoryManager with priority 0.0 for /usr/share/openhab2/runtime/system
[DEBUG] [.impl.DefaultLocalRepositoryProvider] - Using manager SimpleLocalRepositoryManager with priority 0.0 for /var/lib/openhab2/system
[DEBUG] [org.openhab.binding.systeminfo      ] - BundleEvent STARTING - org.openhab.binding.systeminfo
[DEBUG] [org.openhab.binding.systeminfo      ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={component.name=binding.systeminfo, component.id=157, service.id=283, service.bundleid=194, service.scope=bundle} - org.openhab.binding.systeminfo
[DEBUG] [.thing.internal.GenericThingProvider] - ThingHandlerFactory added org.openhab.binding.systeminfo.internal.SysteminfoHandlerFactory@162accd
[DEBUG] [ome.core.thing.internal.ThingManager] - Calling 'SysteminfoHandlerFactory.registerHandler()' for thing 'systeminfo:computer:serv1'.
[DEBUG] [ome.core.thing.internal.ThingManager] - Meta-data of bundle 'org.openhab.binding.systeminfo' is not fully loaded ([org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker$1@b0f550(/ESH-INF/config/), org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker$1@168421c(/ESH-INF/binding/), org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker$1@e17efb(/ESH-INF/thing/)]), deferring handler initialization for thing 'systeminfo:computer:serv1'
[DEBUG] [g.discovery.AbstractDiscoveryService] - Background discovery for discovery service 'org.openhab.binding.systeminfo.discovery.SysteminfoDiscoveryService' enabled.
[DEBUG] [org.openhab.binding.systeminfo      ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={component.name=org.openhab.binding.systeminfo.discovery, component.id=158, service.id=284, service.bundleid=194, service.scope=bundle} - org.openhab.binding.systeminfo
[DEBUG] [mpl.info.InfoBundleTrackerCustomizer] - Ignore incorrect info null provided by bundle org.openhab.binding.systeminfo
[INFO ] [g.apache.aries.spifly.dynamic.bundle] - Bundle Considered for SPI providers: org.openhab.binding.systeminfo
[INFO ] [g.apache.aries.spifly.dynamic.bundle] - No 'SPI-Provider' Manifest header. Skipping bundle: org.openhab.binding.systeminfo
[DEBUG] [org.openhab.binding.systeminfo      ] - BundleEvent STARTED - org.openhab.binding.systeminfo
[DEBUG] [ig.xml.osgi.XmlDocumentBundleTracker] - Reading the XML document '/ESH-INF/binding/binding.xml' in module 'org.openhab.binding.systeminfo'...
[DEBUG] [ig.xml.osgi.XmlDocumentBundleTracker] - Create an empty XmlDocumentProvider for the module 'org.openhab.binding.systeminfo'.
[DEBUG] [ig.xml.osgi.XmlDocumentBundleTracker] - Reading the XML document '/ESH-INF/thing/computer.xml' in module 'org.openhab.binding.systeminfo'...
[DEBUG] [ig.xml.osgi.XmlDocumentBundleTracker] - Create an empty XmlDocumentProvider for the module 'org.openhab.binding.systeminfo'.
[DEBUG] [ig.xml.osgi.XmlDocumentBundleTracker] - Reading the XML document '/ESH-INF/thing/channels.xml' in module 'org.openhab.binding.systeminfo'...
[DEBUG] [ig.xml.osgi.XmlDocumentBundleTracker] - Reading the XML document '/ESH-INF/config/computerConfig.xml' in module 'org.openhab.binding.systeminfo'...
[DEBUG] [ig.xml.osgi.XmlDocumentBundleTracker] - Create an empty XmlDocumentProvider for the module 'org.openhab.binding.systeminfo'.
[DEBUG] [ig.xml.osgi.XmlDocumentBundleTracker] - Reading the XML document '/ESH-INF/config/channelConfig.xml' in module 'org.openhab.binding.systeminfo'...
[DEBUG] [ome.core.thing.internal.ThingManager] - 'org.openhab.binding.systeminfo' still vetoed by '[org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker$1@b0f550(/ESH-INF/config/), org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker$1@e17efb(/ESH-INF/thing/)]'
[DEBUG] [ome.core.thing.internal.ThingManager] - 'org.openhab.binding.systeminfo' queued '[org.openhab.binding.systeminfo.handler.SysteminfoHandler@1b37dc4]'
[DEBUG] [ome.core.thing.internal.ThingManager] - 'org.openhab.binding.systeminfo' still vetoed by '[org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker$1@e17efb(/ESH-INF/thing/)]'
[DEBUG] [ome.core.thing.internal.ThingManager] - 'org.openhab.binding.systeminfo' queued '[org.openhab.binding.systeminfo.handler.SysteminfoHandler@1b37dc4]'
[DEBUG] [ding.astro.handler.AstroThingHandler] - AstroThingConfig[thing=astro:moon:local,geolocation=32.9358,-96.7853,interval=300,systemTimezone=America/Chicago (CST -0600),daylightSavings=false]
[DEBUG] [ding.astro.handler.AstroThingHandler] - AstroThingConfig[thing=astro:sun:local,geolocation=32.9358,-96.7853,interval=300,systemTimezone=America/Chicago (CST -0600),daylightSavings=false]
[DEBUG] [thome.binding.ntp.handler.NtpHandler] - ntp:ntp:local delta system time: -14
[DEBUG] [ome.core.thing.internal.ThingManager] - Finished loading meta-data of bundle 'org.openhab.binding.systeminfo'
[DEBUG] [ome.core.thing.internal.ThingManager] - Calling initialize handler for thing 'systeminfo:computer:serv1' at 'org.openhab.binding.systeminfo.handler.SysteminfoHandler@1b37dc4'.
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Start initializing!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Thing configuration updated!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Channel configuration updated!
[DEBUG] [shaded.org.apache.http.wire         ] - http-outgoing-0 << "    <feature name="openhab-binding-systeminfo1" description="System Info Binding (1.x)" version="1.9.0.SNAPSHOT">[\n]"
[DEBUG] [shaded.org.apache.http.wire         ] - http-outgoing-0 << "        <configfile finalname="${openhab.conf}/services/systeminfo.cfg" override="false">mvn:org.openhab.addons/openhab-addons-external/1.9.0-SNAPSHOT/cfg/systeminfo</configfile>[\n]"
[DEBUG] [shaded.org.apache.http.wire         ] - http-outgoing-0 << "        <bundle start-level="80">mvn:org.openhab.binding/org.openhab.binding.systeminfo/1.9.0-SNAPSHOT</bundle>[\n]"
[DEBUG] [javax.xml.bind                      ] - Checking system property javax.xml.bind.context.factory
[DEBUG] [javax.xml.bind                      ] - Checking system property javax.xml.bind.JAXBContext
[DEBUG] [systeminfo.handler.SysteminfoHandler] - OSHI Systeminfo library is instatiated!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Start reading Thing configuration.
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Refresh time for medium priority channels set to 60 s
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Refresh time for high priority channels set to 1 s
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Properties updated!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Schedule high priority tasks at fixed rate 1 s.
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Schedule medium priority tasks at fixed rate 60 s.
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Schedule one time update for low priority tasks.
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Thing is successfully initialized!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Refresh command received for channel systeminfo:computer:serv1:memory#availablePercent!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Refresh command received for channel systeminfo:computer:serv1:storage#availablePercent!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Refresh command received for channel systeminfo:computer:serv1:sensors#cpuTemp!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Refresh command received for channel systeminfo:computer:serv1:cpu#load!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Refresh command received for channel systeminfo:computer:serv1:cpu#uptime!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Refresh command received for channel systeminfo:computer:serv1:swap#availablePercent!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Refresh command received for channel systeminfo:computer:serv1:battery#remainingCapacity!
[DEBUG] [systeminfo.handler.SysteminfoHandler] - Refresh command received for channel systeminfo:computer:serv1:network#ip!
[DEBUG] [javax.xml.bind                      ] - Checking system property javax.xml.bind.context.factory
[DEBUG] [javax.xml.bind                      ] - Checking system property javax.xml.bind.JAXBContext
[DEBUG] [url.mvn.internal.AetherBasedResolver] - Resolved (org.apache.karaf.features:framework:xml:features:4.0.4) as /usr/share/openhab2/runtime/system/org/apache/karaf/features/framework/4.0.4/framework-4.0.4-features.xml
[DEBUG] [url.mvn.internal.AetherBasedResolver] - Resolved (org.apache.karaf.features:standard:xml:features:4.0.4) as /usr/share/openhab2/runtime/system/org/apache/karaf/features/standard/4.0.4/standard-4.0.4-features.xml
[DEBUG] [url.mvn.internal.AetherBasedResolver] - Resolved (org.openhab.distro:openhab-aggregate-xml:xml:features:2.0.0-SNAPSHOT) as /usr/share/openhab2/runtime/system/org/openhab/distro/openhab-aggregate-xml/2.0.0-SNAPSHOT/openhab-aggregate-xml-2.0.0-SNAPSHOT-features.xml
[DEBUG] [url.mvn.internal.AetherBasedResolver] - Resolved (org.ops4j.pax.web:pax-web-features:xml:features:4.2.4) as /usr/share/openhab2/runtime/system/org/ops4j/pax/web/pax-web-features/4.2.4/pax-web-features-4.2.4-features.xml
[DEBUG] [apache.commons.httpclient.HttpClient] - Operating system name: Linux
[DEBUG] [apache.commons.httpclient.HttpClient] - Operating system architecture: i386
[DEBUG] [apache.commons.httpclient.HttpClient] - Operating system version: 3.16.0-4-686-pae
[DEBUG] [org.eclipse.jetty.http.HttpParser   ] - parseNext s=START HeapByteBuffer@10a2050[p=0,l=449,c=8192,r=449]={<<<GET /icon/battery...: max-age=0\r\n\r\n>>>Cache-Control: ma...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
[DEBUG] [org.eclipse.jetty.server.HttpChannel] - HttpChannelOverHttp@186e2c{r=1,c=false,a=IDLE,uri=/icon/battery?state=0.0&format=svg} messageComplete
[DEBUG] [org.eclipse.jetty.server.HttpChannel] - HttpChannelOverHttp@186e2c{r=1,c=false,a=IDLE,uri=/icon/battery?state=0.0&format=svg} handle enter
[DEBUG] [org.eclipse.jetty.server.HttpChannel] - HttpChannelOverHttp@186e2c{r=1,c=false,a=DISPATCHED,uri=/icon/battery?state=0.0&format=svg} action REQUEST_DISPATCH
[DEBUG] [org.eclipse.jetty.server.Server     ] - REQUEST GET /icon/battery on HttpChannelOverHttp@186e2c{r=1,c=false,a=DISPATCHED,uri=/icon/battery?state=0.0&format=svg}
[DEBUG] [ax.web.service.spi.model.ServerModel] - Matching [/icon/battery]...
[DEBUG] [ax.web.service.spi.model.ServerModel] - Path [/icon/battery] matched to {pattern=/icon/.*,model=ServletModel{id=org.ops4j.pax.web.service.spi.model.ServletModel-10,name=org.ops4j.pax.web.service.spi.model.ServletModel-10,urlPatterns=[/icon/*],alias=/icon,servlet=org.eclipse.smarthome.ui.icon.internal.IconServlet@1f8e6ce,initParams={},context=ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-9,name=,httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.icon_0.9.0.201611241831 [135], contextID=default],contextParams={},virtualHosts={},connectors={}}}}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.icon_0.9.0.201611241831 [135], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - context=||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.icon_0.9.0.201611241831 [135], contextID=default]}
[DEBUG] [eclipse.jetty.servlet.ServletHandler] - servlet |/icon|/battery -> org.ops4j.pax.web.service.spi.model.ServletModel-10@b9f03e57==org.eclipse.smarthome.ui.icon.internal.IconServlet,-1,true
[DEBUG] [ce.jetty.internal.HttpServiceContext] - Handling request for [/icon/battery] using http context [DefaultHttpContext [bundle=org.eclipse.smarthome.ui.icon_0.9.0.201611241831 [135], contextID=default]]
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ o.e.j.s.h.ContextHandler@c7652c{/static,null,AVAILABLE}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.core.audio_0.9.0.201611241831 [97], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=com.eclipsesource.jaxrs.publisher_5.3.1.201602281253 [11], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui_0.9.0.201611241831 [134], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=org.jupnp.transport.impl.osgi.DisableAuthenticationHttpContext@1f408d6}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.ui.dashboard_2.0.0.201611241944 [169], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.basic_0.9.0.201611241831 [175], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.paper_0.9.0.201611241831 [177], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.ui.habpanel_2.0.0.201611252320 [179], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.io.rest.docs_2.0.0.201611252320 [189], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=org.openhab.io.net.http.SecureHttpContext@1f9afc2}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.ui.habmin_2.0.0.201611252320 [209], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.core_2.0.0.201611241944 [165], contextID=default]}
[DEBUG] [org.eclipse.jetty.server.Server     ] - RESPONSE /icon/battery  200 handled=true
[DEBUG] [org.eclipse.jetty.http.HttpParser   ] - parseNext s=START HeapByteBuffer@10a2050[p=0,l=449,c=8192,r=449]={<<<GET /icon/battery...: max-age=0\r\n\r\n>>>\nCache-Control: m...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
[DEBUG] [org.eclipse.jetty.server.HttpChannel] - HttpChannelOverHttp@1aa70f5{r=1,c=false,a=IDLE,uri=/icon/battery?state=0.0&format=svg} messageComplete
[DEBUG] [org.eclipse.jetty.server.HttpChannel] - HttpChannelOverHttp@1aa70f5{r=1,c=false,a=IDLE,uri=/icon/battery?state=0.0&format=svg} handle enter
[DEBUG] [org.eclipse.jetty.server.HttpChannel] - HttpChannelOverHttp@1aa70f5{r=1,c=false,a=DISPATCHED,uri=/icon/battery?state=0.0&format=svg} action REQUEST_DISPATCH
[DEBUG] [org.eclipse.jetty.server.Server     ] - REQUEST GET /icon/battery on HttpChannelOverHttp@1aa70f5{r=1,c=false,a=DISPATCHED,uri=/icon/battery?state=0.0&format=svg}
[DEBUG] [ax.web.service.spi.model.ServerModel] - Matching [/icon/battery]...
[DEBUG] [ax.web.service.spi.model.ServerModel] - Path [/icon/battery] matched to {pattern=/icon/.*,model=ServletModel{id=org.ops4j.pax.web.service.spi.model.ServletModel-10,name=org.ops4j.pax.web.service.spi.model.ServletModel-10,urlPatterns=[/icon/*],alias=/icon,servlet=org.eclipse.smarthome.ui.icon.internal.IconServlet@1f8e6ce,initParams={},context=ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-9,name=,httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.icon_0.9.0.201611241831 [135], contextID=default],contextParams={},virtualHosts={},connectors={}}}}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.icon_0.9.0.201611241831 [135], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - context=||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.icon_0.9.0.201611241831 [135], contextID=default]}
[DEBUG] [eclipse.jetty.servlet.ServletHandler] - servlet |/icon|/battery -> org.ops4j.pax.web.service.spi.model.ServletModel-10@b9f03e57==org.eclipse.smarthome.ui.icon.internal.IconServlet,-1,true
[DEBUG] [ce.jetty.internal.HttpServiceContext] - Handling request for [/icon/battery] using http context [DefaultHttpContext [bundle=org.eclipse.smarthome.ui.icon_0.9.0.201611241831 [135], contextID=default]]
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ o.e.j.s.h.ContextHandler@c7652c{/static,null,AVAILABLE}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.core.audio_0.9.0.201611241831 [97], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=com.eclipsesource.jaxrs.publisher_5.3.1.201602281253 [11], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui_0.9.0.201611241831 [134], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=org.jupnp.transport.impl.osgi.DisableAuthenticationHttpContext@1f408d6}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.ui.dashboard_2.0.0.201611241944 [169], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.basic_0.9.0.201611241831 [175], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.paper_0.9.0.201611241831 [177], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.ui.habpanel_2.0.0.201611252320 [179], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.io.rest.docs_2.0.0.201611252320 [189], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=org.openhab.io.net.http.SecureHttpContext@1f9afc2}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.ui.habmin_2.0.0.201611252320 [209], contextID=default]}
[DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/icon/battery @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.core_2.0.0.201611241944 [165], contextID=default]}
[DEBUG] [org.eclipse.jetty.server.Server     ] - RESPONSE /icon/battery  304 handled=true
ThomDietrich commented 7 years ago

Nothing in there helping your case. You might need to check the source code. Is the openhab user permitted to cat /sys/class/power_supply/BAT0/capacity? Are there other systemInfo properties you are not able to retrieve?

DaAwesomeP commented 7 years ago

I think that I just found the problem. I tested the values of battery name and time remaining. The value of battery#name was AC, and the value of battery#remainingTime was 999.0. So, these values must be being recorded from the AC adapter, not the battery. This would explain why capacity is 0. However, the file capacity does not exist in /sys/class/power_supply/AC/.

ThomDietrich commented 7 years ago

Interesting. Well an AC does not really have a capacity, maybe it's intentionally left out. For me it would be interesting to know why AC instead of BAT0 is read on your system. There could either be a bug in the systeminfo binding or you need to supply "BAT0" somehow. Could you check the sourcecode? Would be incredible if you were able to contribute a fix ;)

DaAwesomeP commented 7 years ago

Well, when the battery is attached, and the AC adapter is plugged in, technically the AC adapter is the active power source, so it may be selecting it for that reason. I'll see what I can figure out from the sources, but I have basically no experience with Java.

DaAwesomeP commented 7 years ago

I think that I found the issue. OSHI ignores power supplies beginning with the name ADP, but the name of mine is simply AC. So, it should change:

diff --git a/oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxPowerSource.java b/oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxPowerSource.java
index c979698..153dbf5 100644
--- a/oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxPowerSource.java
+++ b/oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxPowerSource.java
@@ -63,8 +63,8 @@ public class LinuxPowerSource extends AbstractPowerSource {
         List<LinuxPowerSource> psList = new ArrayList<>(psNames.length);
         // For each power source, output various info
         for (String psName : psNames) {
-            // Skip if name is ADP* (AC power supply)
-            if (psName.startsWith("ADP")) {
+            // Skip if name is ADP* or AC* (AC power supply)
+            if (psName.startsWith("ADP") || psName.startsWith("AC")) {
                 continue;
             }
             // Skip if can't read uevent file

I can't really compile/implement this into OpenHAB myself, but I'd be happy to submit a pull if someone sent me a JAR (and instructions on where to put it) for testing.

OSHI is reading /sys/class/power_supply/<name>/uevent. Here is the contents of /sys/class/power_supply/AC/uevent:

POWER_SUPPLY_NAME=AC
POWER_SUPPLY_ONLINE=1

The contents of /sys/class/power_supply/BAT0/uevent:

POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
POWER_SUPPLY_VOLTAGE_NOW=12402000
POWER_SUPPLY_CURRENT_NOW=1000
POWER_SUPPLY_CHARGE_FULL_DESIGN=4400000
POWER_SUPPLY_CHARGE_FULL=4048000
POWER_SUPPLY_CHARGE_NOW=4012000
POWER_SUPPLY_CAPACITY=99
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=DELL MT2648
POWER_SUPPLY_MANUFACTURER=Samsung SDI
POWER_SUPPLY_SERIAL_NUMBER=427

So, the other solution would be to skip the power source if the key keys are missing.

DaAwesomeP commented 7 years ago

cc @dbwiddis

dbwiddis commented 7 years ago

I'll get this fixed along with many other things in the last week of the year.

DaAwesomeP commented 7 years ago

Thanks!

DaAwesomeP commented 7 years ago

@ThomDietrich @svilenvul OSHI has been updated accordingly (oshi/oshi#278 is closed). Please update the addon. Thanks!

dbwiddis commented 7 years ago

Currently the fix is only in the SNAPSHOT release but I expect the full 3.3 release soon.

svilenvul commented 7 years ago

I will update the binding with oshi 3.4, so I guess this will solve the issue.

dbwiddis commented 7 years ago

FYI, don't use 3.4.1 unless you want to subject yourself to GPLv2 license. Use 3.4.0 (Java 8) or wait for 3.4.2 (Java 7) in a few hours.

svilenvul commented 7 years ago

OK, thanks @dbwiddis

dbwiddis commented 7 years ago

3.4.2 has been released. May take a few hours to show up on Central but you're probably safe to update your dependencies and commit changes.

DaAwesomeP commented 7 years ago

Thanks!