Yea, thanks for feedback Pedro_Liberal,
it feels great when we learn a more efficient way of doing something.
Thats my up to date integration V2, being cleaned up and more focused on OH4, i workd on OH4 for testing, while OH2 setup is left working in poduction, bsically it could work on OH2 also if transform would be done in things.
But i didn’t bother making so many channels like for smart plug in MQTT.things for ShellyEM3Pro in OH4 as it is capable of on the fly conversion in items, so it takes less space in things alongside other devices, so i moved as much to items as posible to have clean setup.
MQTT.things
Thing mqtt:topic:shelly3em "Shelly 3EM Pro" {
Channels:
Type string : em_status "EM Status" [ stateTopic="Shelly-3EM/status/em:0" ]
Type string : emdata "EM Data" [ stateTopic="Shelly-3EM/status/emdata:0" ]
//Type string : rpc "RPC Events" [ stateTopic="Shelly-3EM/events/rpc" ]
Type string : online "Online" [ stateTopic="Shelly-3EM/online" ]
Type string : rpc_command "RPC Command" [ commandTopic="Shelly-3EM/rpc" ]
Type string : rpc_response "RPC Response" [ stateTopic="Shelly-3EM/OH_Shelly.GetStatus/rpc" ]
Type string : errors [ stateTopic="Shelly-3EM/status/em:0", transformationPattern="JS:shelly_errors.js" ]
}
Shelly_EM3_V2.items
Group Shelly3EM
Group gShelly3EM_Number (Shelly3EM)
Group Shelly_Moc_3F (Shelly3EM)
Group Shelly_Tok_3F (Shelly3EM)
Group Shelly_Napetost_3F (Shelly3EM)
// === FAZA A ===
Number Shelly3EM_A_Current "1.F tok [%s A]" (gShelly3EM_Number, Shelly_Tok_3F) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.a_current"] }
Number Shelly3EM_A_Voltage "1.F napetost [%s V]" (gShelly3EM_Number, Shelly_Napetost_3F) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.a_voltage"] }
Number Shelly3EM_A_ActPower "1.F moč (W) [%s W]" (gShelly3EM_Number, Shelly_Moc_3F) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.a_act_power"] }
Number Shelly3EM_A_PowerFactor "1.F faktor moči [cos φ ~ %s]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.a_pf"] }
// === FAZA B ===
Number Shelly3EM_B_Current "2.F tok [%s A]" (gShelly3EM_Number, Shelly_Tok_3F) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.b_current"] }
Number Shelly3EM_B_Voltage "2.F napetost [%s V]" (gShelly3EM_Number, Shelly_Napetost_3F) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.b_voltage"] }
Number Shelly3EM_B_ActPower "2.F moč (W) [%s W]" (gShelly3EM_Number, Shelly_Moc_3F) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.b_act_power"] }
Number Shelly3EM_B_PowerFactor "2.F faktor moči [cos φ ~ %s]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.b_pf"] }
// === FAZA C ===
Number Shelly3EM_C_Current "3.F tok [%s A]" (gShelly3EM_Number, Shelly_Tok_3F) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.c_current"] }
Number Shelly3EM_C_Voltage "3.F napetost [%s V]" (gShelly3EM_Number, Shelly_Napetost_3F) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.c_voltage"] }
Number Shelly3EM_C_ActPower "3.F moč (W) [%s W]" (gShelly3EM_Number, Shelly_Moc_3F) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.c_act_power"] }
Number Shelly3EM_C_PowerFactor "3.F faktor moči [cos φ ~ %s]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.c_pf"] }
// === SKUPNO ===
Number Shelly3EM_Total_Current "Skupni tok [%s A]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.total_current"] }
Number Shelly3EM_Total_ActPower "Skupna moč [%s W]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.total_act_power"] }
Number Shelly3EM_Total_AprtPower "Skupna navidezna moč [%s VA]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:em_status" [profile="transform:JSONPATH", function="$.total_aprt_power"] }
// === ENERGIJA ===
Number Shelly3EM_A_Total_Energy "1.F poraba [%s Wh]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:emdata" [profile="transform:JSONPATH", function="$.a_total_act_energy"] }
Number Shelly3EM_B_Total_Energy "2.F poraba [%s Wh]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:emdata" [profile="transform:JSONPATH", function="$.b_total_act_energy"] }
Number Shelly3EM_C_Total_Energy "3.F poraba [%s Wh]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:emdata" [profile="transform:JSONPATH", function="$.c_total_act_energy"] }
Number Shelly3EM_Total_Act_Energy "Skupna poraba [%s Wh]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:emdata" [profile="transform:JSONPATH", function="$.total_act"] }
// === ODDANA ENERGIJA ===
Number Shelly3EM_A_Total_RetEnergy "1.F povratna energija [%s Wh]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:emdata" [profile="transform:JSONPATH", function="$.a_total_act_ret_energy"] }
Number Shelly3EM_B_Total_RetEnergy "2.F povratna energija [%s Wh]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:emdata" [profile="transform:JSONPATH", function="$.b_total_act_ret_energy"] }
Number Shelly3EM_C_Total_RetEnergy "3.F povratna energija [%s Wh]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:emdata" [profile="transform:JSONPATH", function="$.c_total_act_ret_energy"] }
Number Shelly3EM_Total_Act_RetEnergy "Skupaj oddana energija [%s Wh]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:emdata" [profile="transform:JSONPATH", function="$.total_act_ret"] }
// === SISTEMSKE METRIKE ===
String Shelly3EM_Napake_Meritev "Napake Meritev [%s]" (Shelly3EM) { channel="mqtt:topic:shelly3em:errors"} // JS tansform dela le v things [profile="transform:js", function="shelly_errors.js"]
String Shelly3EM_Online1 (Shelly3EM) { channel="mqtt:topic:shelly3em:online" }
String Shelly3EM_Rpc_command (Shelly3EM) { channel="mqtt:topic:shelly3em:rpc_command" }
String Shelly3EM_RPC_WiFi_IP "WiFi IP [%s]" (Shelly3EM) { channel="mqtt:topic:shelly3em:rpc_response" [profile="transform:JSONPATH", function="$.result.wifi.sta_ip"] }
String Shelly3EM_RPC_WiFi_Status "WiFi stanje [%s]" (Shelly3EM) { channel="mqtt:topic:shelly3em:rpc_response" [profile="transform:JSONPATH", function="$.result.wifi.status"] }
Number Shelly3EM_WiFi_RSSI "WiFi signal [%s dBm]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:rpc_response" [profile="transform:JSONPATH", function="$.result.wifi.rssi"] }
String Shelly3EM_RPC_Sys_Time "Ura [%s]" (Shelly3EM) { channel="mqtt:topic:shelly3em:rpc_response" [profile="transform:JSONPATH", function="$.result.sys.time"] }
Number Shelly3EM_Sys_Uptime "Uptime [%s s]" (gShelly3EM_Number) { channel="mqtt:topic:shelly3em:rpc_response" [profile="transform:JSONPATH", function="$.result.sys.uptime"] }
String Shelly3EM_RPC_Cloud_Connected "Cloud povezan [%s]" (Shelly3EM) { channel="mqtt:topic:shelly3em:rpc_response" [profile="transform:JSONPATH", function="$.result.cloud.connected"] }
Number Shelly3EM_Temp_C "Temperatura [%s °C]" (gShelly3EM_Number) {channel="mqtt:topic:shelly3em:rpc_response" [profile="transform:JSONPATH", function="$.result.temperature:0.tC"] }
Shelly_EM3_V2.rules
rule "Poizvedba Shelly Status"
when
Time cron "0/10 * * * * ?"
then
Shelly3EM_Rpc_command.sendCommand('{ "id": 2, "src": "Shelly-3EM/OH_Shelly.GetStatus", "method": "Shelly.GetStatus" }')
//ShellyPlug_S1_Command.sendCommand('{ "id": 2, "src": "Vticnice/Shelly-S1/Shelly.GetStatus", "method": "Shelly.GetStatus" }')
end
Shelly sitemap section
Text item=Shelly3EM_C_ActPower label="Shelly - Meritve Energije[(3.F) .. %s W]" icon="shelly_3em_2"
{
Frame
{
Text item=Shelly3EM_RPC_Sys_Time icon="time" label="Čas Meritve"
Text item=Shelly3EM_Online1 icon="link" label="Online"
}
Frame label="Meritve Toka"
{
Default item=Shelly3EM_A_Current label="1. Tok" icon="amps3_l1"
Default item=Shelly3EM_B_Current label="2. Tok" icon="amps2_l2"
Default item=Shelly3EM_C_Current label="3. Tok" icon="amps2_l3"
}
Frame label="Moč"
{
Default item=Shelly3EM_A_ActPower label="1. Aktivna Moč" icon="watts2_l1"
Default item=Shelly3EM_B_ActPower label="2. Aktivna Moč" icon="watts2_l2"
Default item=Shelly3EM_C_ActPower label="3. Aktivna Moč" icon="watts2_l3"
}
Frame label="Skupaj 3F"
{
Default item=Shelly3EM_Total_Current label="Skupni Tok" icon="amps2_ln"
Default item=Shelly3EM_Total_ActPower label="Skupna Moč" icon="watts2_ln"
Default item=Shelly3EM_Total_Act_Energy label="Porabljena Energija" icon="energy_use"
Default item=Shelly3EM_Total_Act_RetEnergy label="Oddana Energija" icon="energy_sun_1"
Text label="Energija in Napetost" icon="energy_detail" labelcolor=["green"]
{
Frame label="Energija"
{
Default item=Shelly3EM_A_Total_Energy label="1. Energija" icon="energy_l1"
Default item=Shelly3EM_B_Total_Energy label="2. Energija" icon="energy_l2"
Default item=Shelly3EM_C_Total_Energy label="3. Energija" icon="energy_l3"
Default item=Shelly3EM_C_Total_RetEnergy label="3. Povratna Energija" icon="energy_l3sun"
}
Frame label="Napetost in PF"{
Default item=Shelly3EM_A_Voltage label="1. Napetost" icon="volts_1_2"
Default item=Shelly3EM_B_Voltage label="2. Napetost" icon="volts_2_2"
Default item=Shelly3EM_C_Voltage label="3. Napetost" icon="volts_3_2"
}
Frame{
Default item=Shelly3EM_Total_AprtPower label="Navidezna Moč" icon="voltamps2"
Default item=Shelly3EM_A_PowerFactor label="1. Faktor Moči" icon="cosfi_1"
Default item=Shelly3EM_B_PowerFactor label="2. Faktor Moči" icon="cosfi_2"
Default item=Shelly3EM_C_PowerFactor label="3. Faktor Moči" icon="cosfi_3"
}
}
}
Frame label="Grafi"
{
Switch item=GrafCas_Meritve label="Časovni Interval" mappings=[h="h",4h="4h",12h="12h",D="D", W="W"]
Chart item=Shelly_Moc_3F refresh=10000 period=h legend=true visibility=[GrafCas_Meritve=="h"]
Chart item=Shelly_Moc_3F refresh=10000 period=4h legend=true visibility=[GrafCas_Meritve=="4h"]
Chart item=Shelly_Moc_3F refresh=10000 period=12h legend=true visibility=[GrafCas_Meritve=="12h"]
Chart item=Shelly_Moc_3F refresh=10000 period=D legend=true visibility=[GrafCas_Meritve=="D"]
Chart item=Shelly_Moc_3F refresh=10000 period=W legend=true visibility=[GrafCas_Meritve=="W"]
Chart item=Shelly3EM_C_ActPower refresh=10000 period=h legend=true visibility=[GrafCas_Meritve=="h"]
Chart item=Shelly3EM_C_ActPower refresh=10000 period=4h legend=true visibility=[GrafCas_Meritve=="4h"]
Chart item=Shelly3EM_C_ActPower refresh=10000 period=12h legend=true visibility=[GrafCas_Meritve=="12h"]
Chart item=Shelly3EM_C_ActPower refresh=10000 period=D legend=true visibility=[GrafCas_Meritve=="D"]
Chart item=Shelly3EM_C_ActPower refresh=10000 period=W legend=true visibility=[GrafCas_Meritve=="W"]
Text label="Več Grafov" icon="line"
{
Switch item=GrafCas_Meritve label="Časovni Interval" mappings=[h="h",4h="4h",12h="12h",D="D", W="W"]
Chart item=Shelly_Tok_3F refresh=10000 period=h legend=true visibility=[GrafCas_Meritve=="h"]
Chart item=Shelly_Tok_3F refresh=10000 period=4h legend=true visibility=[GrafCas_Meritve=="4h"]
Chart item=Shelly_Tok_3F refresh=10000 period=12h legend=true visibility=[GrafCas_Meritve=="12h"]
Chart item=Shelly_Tok_3F refresh=10000 period=D legend=true visibility=[GrafCas_Meritve=="D"]
Chart item=Shelly_Tok_3F refresh=10000 period=W legend=true visibility=[GrafCas_Meritve=="W"]
Chart item=Shelly_Napetost_3F refresh=10000 period=h legend=true visibility=[GrafCas_Meritve=="h"]
Chart item=Shelly_Napetost_3F refresh=10000 period=4h legend=true visibility=[GrafCas_Meritve=="4h"]
Chart item=Shelly_Napetost_3F refresh=10000 period=12h legend=true visibility=[GrafCas_Meritve=="12h"]
Chart item=Shelly_Napetost_3F refresh=10000 period=D legend=true visibility=[GrafCas_Meritve=="D"]
Chart item=Shelly_Napetost_3F refresh=10000 period=W legend=true visibility=[GrafCas_Meritve=="W"]
}
}
Frame label="Sistem"
{
Text item=Shelly3EM_Sys_Uptime icon="time"
Text item=Shelly3EM_WiFi_RSSI label="Signal" icon="wifi"
{
Default item=Shelly3EM_RPC_WiFi_IP label="WiFi IP" icon="link"
Default item=Shelly3EM_RPC_WiFi_Status icon="wifi"
Default item=Shelly3EM_RPC_Cloud_Connected icon="online"
}
Default item=Shelly3EM_Temp_C label="Temperatura" icon="therm"
Text item=Shelly3EM_Napake_Meritev icon="error"
}
}
the JS transform for shelly_errors.js i uploaded in previous post, is left the same.
So posibly there could be made an integration into the Shelly binding to support MQTT comms via my code, but that’s not in my capabilities yet, as i run all text based config.
So i weclome new users, to test out my integration and tell me about the experience, customize it and post it back
.