[SOLVED] No channels created from thing-type.xml

I took it upon me to learn Java and binding development and I made some progress. A first test version of a binding to get data from a Philips Air Purifier is getting along quite nice; the Diffie-Hellman key exchange, the Thing creation, the device status query into a Java object all work fine.

However, as a beginner on this topic, I somehow overlook an important piece of information. For some reason, the channels are not created. The relevant pieces of code are below (I am now testing with just one channel).

thing-type.xml:

<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="philipsair"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
	xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

	<!-- Philips Air Purifier Thing Type -->
	<thing-type id="philipsair">
		<label>Philips Air Purifier</label>
		<description>
			Provides air quality data from the Philips Air Cleaner and Humidifier.
			In order to connect, the connection with the App (iOS or Android) must have been created first.
		</description>
		<channels>
			<channel id="temperature" typeId="temperature" />
		</channels>
		<config-description>
			<parameter name="ipAddress" type="text" required="true">
				<label>IP Address</label>
				<description>IP address of the Philips air cleaner and humidifier</description>
			</parameter>
			<parameter name="refresh" type="integer" min="1" required="false">
				<label>Refresh interval</label>
				<description>The refresh interval in minutes.</description>
				<default>10</default>
			</parameter>
		</config-description>
	</thing-type>
	<channel-type id="temperature">
		<item-type>Number:Temperature</item-type>
		<label>Temperature</label>
		<description>Current temperature</description>
		<category>Temperature</category>
		<state readOnly="true"/>
	</channel-type>
</thing:thing-descriptions>

PhilipsJsonResponse.java:

public class PhilipsAirJsonResponse {

    @SerializedName("temp")
    public BifgDecimal temperature;

    public BigDecimal getTemperature() {
        return temperature;
    }
}

PhilipsAirHandler.java:

    private void startAutomaticRefresh() {
        if (refreshJob == null || refreshJob.isCancelled()) {
            Runnable runnable = () -> {
                try {
                    airResponse = getPhilipsAirData();
                    for (Channel channel : getThing().getChannels()) {
                        logger.debug("Update channel {}", channel);
                        updateChannel(channel.getUID().getId(), airResponse);
                    }
                } catch (Exception e) {
                    logger.error("Exception occurred during execution: {}", e.getMessage(), e);
                }
                logger.debug("Refresh job done");
            };
            PhilipsAirConfiguration config = getConfigAs(PhilipsAirConfiguration.class);
            refreshJob = scheduler.scheduleWithFixedDelay(runnable, 0, config.refreshRate, TimeUnit.SECONDS);
        }
    }

The airResponse object gets the required data from the JSON response, but no channels are found to update.
I looked at other bindings, but could not see a relevant difference related to this (except for bindings that created dynamic channels). I must be blind somehow, so what am I missing?

Would be easier to help if you commit your work to your github repo and post the according link. With just your snippets it is hard to tell what needs to be changed.

Will do, thanks.

The source of this pre-alpha binding version is on GitHub.
Any comments, feedback is appreciated. I’m here to learn but my immediate need is to get the channels created.

Anyone? ;o)

openhab> smarthome:items list
LR_PA_Temp (Type=NumberItem, State=NULL, Label=Temperature, Category=temperature)
openhab> smarthome:links list
LR_PA_Temp -> philipsair:fan:ac2790:temperature
openhab> smarthome:things list
philipsair:fan:ac2790 (Type=Thing, Status=ONLINE, Label=Air Purifier Livingroom, Bridge=null)
openhab> smarthome:things show philipsair:fan:ac2790
UID: philipsair:fan:ac2790
Type: philipsair:fan
Label: Air Purifier Livingroom
Status: ONLINE

No properties

Configuration parameters:
        ipAddress : 192.168.1.164
        refreshRate : 120

No channels
openhab>

I tried your binding, but found an issue:

If you update the jar you need to recreate the thing.

I created a thing in PaperUi with automatic item linking and had the channel. Could it be you have no channels configured and linked to items?

1 Like

Thanks, Hilbrand. I did change to ‘fan’ at some point. Must have overlooked this one…

UPDATE: That did it!