[SOLVED] How can i control the gpios of a raspberry pi through google assistant

@sihui i tried but google home didnt list it after setting it up and linking tha accounts

Please see How to ask a good question / Help Us Help You. We could waste everyone’s time playing 20 Questions or you can tell us what you’ve done on what version of OH and we can help tell you where you went wrong.

We cannot help you troubleshoot your secret configuration. We provide HELP not complete solutions. If you do not show us what does not work, we cannot assist you.

ok so
im using open hab 2 on rpi 3

Switch fan "enchufe 2" <poweroutlet_us> { gpio="pin:17 activelow:yes initialVal$

Switch night_light “Enchufe 1” <poweroutlet_us> { gpio="pin:27 activelow:yes in$
Switch exhaust “Luz 1” { gpio=“pin:23 activelow:yes initialValue:high” }
Switch light “Luz 2” { gpio=“pin:5 activelow:yes initialValue:low” }

String VoiceCommand

this is my home.items file

sitemap home label=“Smart Home”
{
Frame label=“My Room”
{
Switch item=fan
Switch item=light
Switch item=exhaust
Switch item=night_light
}
}

this is my sitemap file

import org.openhab.model.script.actions.*
import org.openhab.core.library.types.*
import java.util.*

rule “voice”

when
Item VoiceCommand received command
then
var String command = VoiceCommand.state.toString.toLowerCase
logInfo(“Voice.Rec”,"VoiceCommand received "+command)

if (command.contains(“prende el enchufe 1”) || (command.contains(“prende enchufe 1”))) {
fan.sendCommand(ON)
}
else if (command.contains(“apaga enchufe 1”) || (command.contains(“apaga el enchufe 1”))) {
fan.sendCommand(OFF)
}
else if (command.contains(“apaga la luz 1”) || (command.contains(“apaga luz 1”))) {
light.sendCommand(OFF)
}
else if (command.contains(“prende luz 1”) || (command.contains(“prende la luz 1”))) {
light.sendCommand(ON)
}
else if (command.contains(“prende luz 2”) || (command.contains(“prende la luz 2”))) {
night_light.sendCommand(ON)
}
else if (command.contains(“apaga luz 2”) || (command.contains(“apaga la luz 2”))) {
night_light.sendCommand(OFF)
}
else if (command.contains(“turn on exhaust fan”) || (command.contains(“turn on the exhaust fan”))) {
exhaust.sendCommand(ON)
}
else if (command.contains(“turn off exhaust fan”) || (command.contains(“turn off the exhaust fan”))) {
exhaust.sendCommand(OFF)
}
end
and this the rules file,

i have the open hab cloud connector addon installed alongside gpio bindings.

now when i set up open hab through the app i can control the leds but when i try to link google assistant to my openhab account nothing happens and my items arent listed on the google home app nor the google assitant settings.

And where are the tags for Google Assistant as documented by Sihui above in the second post? You still did not read and follow the official documentation.

i dind understand that part, i read it, sorry im new to this,

Switch fan “enchufe 2” <poweroutlet_us> { gpio=“pin:17 activelow:yes initialValue:low” } (gBedroom) { ga=“Outlet” }
Switch night_light “Enchufe 1” <poweroutlet_us> { gpio=“pin:27 activelow:yes initialValue:high” } (gBedroom) { ga=“Outlet2” }
Switch exhaust “Luz 1” { gpio=“pin:23 activelow:yes initialValue:high” } (gBedroom) { ga=“Light” }
Switch light “Luz 2” { gpio=“pin:5 activelow:yes initialValue:low” } (gBedroom) { ga=“Light2” }

would something like this work

Google Assistant does not understand “Outlet2” or “Light2” Types. My guess would be

Switch fan "enchufe 2" <poweroutlet_us> { gpio="pin:17 activelow:yes initialValue:low" ga="Outlet" } (gBedroom) 
Switch night_light "Enchufe 1" <poweroutlet_us> { gpio="pin:27 activelow:yes initialValue:high"  ga="Outlet" } (gBedroom) 
Switch exhaust "Luz 1" { gpio="pin:23 activelow:yes initialValue:high" ga="Light" } (gBedroom) 
Switch light "Luz 2" { gpio="pin:5 activelow:yes initialValue:low" ga="Light" } (gBedroom)

Using code fences here shows us exactly how your configuration is spaced. The type of quotes look wrong too, but that may have been just the forum messing things up.

How to use code fences - Tutorials & Examples - openHAB Community

I didn’t read Sihui’s link and I don’t use google but does it still work with tagging such as [“Lighting”] ?

@Marcos_Villar Seems I remember you can have the item tagged both ways and it will work so maybe try changing your item like below:

Switch night_light "Enchufe 1" <poweroutlet_us> ["Lighting"] { gpio="pin:27 activelow:yes initialValue:high"  ga="Outlet" } (gBedroom)

The tag is the “ga=” part. I just followed their configuration posted upthread.

Currently the following metadata values are supported (also depending on Googles API capabilities):

  • Switch / Dimmer / Color { ga="Light" }
  • Switch { ga="Switch" }
  • Switch { ga="Outlet" }
  • Switch { ga="CoffeeMaker" }
  • Switch { ga="WaterHeater" }
  • Switch { ga="Fireplace" }
  • Switch { ga="Valve" }
  • Switch { ga="Sprinkler" }
  • Switch { ga="Vacuum" }
  • Switch { ga="Scene" }
  • Switch { ga="Lock" [ tfaAck=true ] }
  • Switch { ga="SecuritySystem" [ tfaPin="1234" ] }
  • Dimmer { ga="Speaker" }
  • Switch / Dimmer { ga="Fan" [ speeds="0=away:zero,50=default:standard:one,100=high:two", lang="en", ordered=true ] } (for Dimmer the options have to be set)
  • Switch / Dimmer { ga="Hood" }
  • Switch / Dimmer { ga="AirPurifier" }
  • Rollershutter { ga="Awning" [ inverted=true ] } (all Rollershutter items can use the inverted option)
  • Rollershutter { ga="Blinds" }
  • Rollershutter { ga="Curtain" }
  • Rollershutter { ga="Door" }
  • Rollershutter { ga="Garage" }
  • Rollershutter { ga="Gate" }
  • Rollershutter { ga="Pergola" }
  • Rollershutter { ga="Shutter" }
  • Rollershutter { ga="Window" }
  • Group { ga="Thermostat" }
  • Number { ga="thermostatTemperatureAmbient" } as part of Thermostat group
  • Number { ga="thermostatHumidityAmbient" } as part of Thermostat group
  • Number { ga="thermostatTemperatureSetpoint" } as part of Thermostat group
  • Number / String { ga="thermostatMode" } as part of Thermostat group
  • String { ga="Camera" [ protocols="hls,dash" ] }

It helps a lot to How to use code fences.

Your Items are cut off, we need to see the whole line.

Do not import with wild cards.

Do not import anything from org.openhab or org.eclipse.smarthome, they haven’t been required since OHI 2.0.

Order matters when defining Items. The Group (stuff in ()) needs to go between the icon <> and the binding config { }.

If one is just getting started with GA integration, using metadata instead of tags should be the way. Better to get started using the approach that will be used going forward.

I agree, :+1: but at this point I was only trying to get something verified as working so they can move on. :laughing:

ok, so this is the required syntax

Switch exhaust “luz1” (gKitchen) { gpio=“pin:23 activelow:yes initialValue:high” ga=“Switch” }

and this could be repeated for the other items?

No you have the wrong quotes, try:

Switch exhaust "luz1" (gKitchen) { gpio="pin:23 activelow:yes initialValue:high", ga="Switch" }

If this item work then yes you can repeat for the others. If not then post the errors you have in the logs.

And please post rules, items, sitemaps, logs, etc… in code fences.

1 Like

Don’t forget the comma :grinning:

...high", ga="...

1 Like

Yep, I deleted it when changing the quotes. :upside_down_face:

Nice catch and thanks. :+1:

EDIT:
Never mind, the comma was never there to begin with. Not my mistake, I’m still perfect :rofl:, :lying_face:

2 Likes

Don’t make us ask your wife… :wink:

3 Likes

:grimacing:,:shushing_face:, :zipper_mouth_face:

1 Like

IT WORKED i finnaly have the items set up

1 Like

We helped you AND you understand how it works so you can maintain it.
Good job!