Setting up Esp8266 PIR sensor in openhab2 with MQTT (im stumped)

Should my item line have the map file at the end ?

Right now is

Number sensors_frontdoor_pir "Front Door Motion [MAP(esp-pir.map):%s]" <motion> (Gcontacts) {mqtt=">[mosquitto:mtsensor/pir/Contact:state:default]"}

Should it be this?

Number sensors_frontdoor_pir "Front Door Motion" <motion> (Gcontacts) {mqtt=">[mosquitto:mtsensor/pir/Contact:state:MAP(esp-pir.map):]"}

Also can someone explain what is the difference between %d and %s ?

I was also reading in the openhab2 documentation and came across this below .Should there be 2 seperate lines in the item file?

No. In that example they do show you just the difference between a transformed item and a default item.

%s: use item value as string
%d: use item value as integer

So i tried using just %d instead of the map to see if i can get it to display just a 0 or 1 but this isnt working either .Its just displaying - I cant see why this is not working .The Mqtt is definitly working as per my mqttfx test and im sure the topic is correct. Maybe a glitch in openhab2? The temp sensor is also on the same esp device and that is working fine. Everything is working except for displaying a value in openhab . I did install the map transform in paperui as well. It just seems like openhab is not accepting a 0 or 1 .

I would like to get it working with the current 0 or 1 values but if not i may have to change it to a contact item. If i do how do i transform a 0 or 1 into a open / closed ? Do i just change number to contact and in map write
0=closed
1=open

Also i have a idea that openhab2 is looking for a decimal value like 0.00/1.00 instead of what the sensor is putting out which is 0/1 .Would it be possible to change the value in espeasy so it sends the decimal values instead of 0 or 1? Maybe a rule or something?

BTW i appreciate you taking the time to help

Oh man ! i found the problem and it was super simple. I put a publish arrow instead of a subscribe by accident .It was > . Im surprised nobody here caught it since i posted the item line a bunch of times. lol All good now.

Now to make another mqtt lightswitch turn on when there is motion .I do this in rules correct?

Thanks .Thats what i had in mind. My only question is with the motion sensor im using that sends a value of 0 or 1 and then is transformed to still or motion , what do i use in the rule ? Can i use the tranformed variable of still or motion or do i use 0 or 1 ? I cant seem to find anything about this in the openhab2 documentation

You need to use the map transformation in the channel definition, not in the label, then your are able to trigger on that state in rules:

item:

Switch MQTT_Item "Test MQTT item trigger" {mqtt="<[mosquitto:/esp8266two/test/switch:state:MAP(test.map)],<[mosquitto:/esp8266two/test/switch:command:ON:1.00],<[mosquitto:/esp8266two/test/switch:command:OFF:0.00]"}

map:

0.00=OFF
1.00=ON
-=undefiniert
NULL=undefiniert

rule:

rule "test"
when   
		Item MQTT_Item changed from OFF to ON
then
		//do stuff